Override Values In Textbox linked to tables

Gman

Registered User.
Local time
Today, 11:54
Joined
Oct 17, 2008
Messages
39
Hello all,

I have two tables, one is roominfo and the other is roomtypes.
Each table has about 10 fields, and have a relationship based on one field in each.

I have added a qurey that links the two table together, all records in the roominfo are shown in the query. The linked field has a combobox(row source equal to one field in roomtypes) that looks up data in the roomtypes, which allow the user to select the type of room, then populates the the query record.

I have builtd a form that thats looks at the query, in the form you fill out the room info data, and the you use the combobox to select the room types. When the room type is selected, it populates the rest of the textboxes.

What I would like to do is be able to overwrite the tetxboxes in the form that are populated based on the combobox. I need to able to override some data but if I override them, it changes the roomtype data. I want the roomtype data to remain and not be changed.

I first did this with just the using control source, then I detemriend that I should use VBA code, so that I can be able to overwrite them in the form, and then linke them to the roominfo table instead. I just use the roomtypes with a dlookup to populates the form.

Also, when I overwrite certain textboxes, I want the text to change color so that I know whichs ones were overwritten. Then if I enter say an * in the textbox, i want the textbox to revert back the roominfo table..

I know that I this can be down with vba code, but it was starting to get complex with my code. Is ther a better way to go than this way.
 

Attachments

Last edited:
The crux is you need an event to put the form into the new mode that prevents the changing of dependent boxes.

If you can populate the roomtype dependent boxes just using logic in their Record Source then perhaps you could include a test for the mode flag to stop them updating.

Starting to sound like replacing VBA with a massive Record Source logic but worth a thought since you have the main logic already done.

How about if you just lock the dependent fields after the mode change? Haven't tried this at all. Just a little simple VBA to do that.

If you then link the boxes to the table you will have to store their value first and then restore it after the change so I think that would be clumsy. Would it be simpler to run an SQL command to load the fields back to the table when a Save button was pressed?

I think the colour change would be have to be an OnChange or OnUpdate event on each box.
Otherwise it would be some fairly elaborate conditional formatting.

Entering the * to release the lock is definitely VBA. What about a right click to reset? OnMouse Down can detect the key used.

In the end I think the VBA is probably the way to go for the lot.
 
Thanks for your reply,

Sounds like the best way is to trigger events and run vba code to do what I need,

Thanks
 

Users who are viewing this thread

Back
Top Bottom