Question

I am tasked with fixing some errors the users are having with a smaller MS Access DB and I was curious if I could get access to the current update query that the form is using when data is edited before it goes into the database.

For example I on a form that a user has there is a combo box to specify if certain data is the same for 2 different instances and currently the application painfully creates the query manually by grabbing the values of each text box.

I was wondering if I could use a BeforeUpdate event or similar to grab the update query that the form is going to run and modify it based on the combo box instead of having to manually grab each of the values from the text box as there are several text boxes.

Edit:

It doesn't actually get any errors, but if the users don't click the add button and instead just type the data in the blank text boxes and click the save button the form will insert the data into the database without errors, but the foreign key to the join table will be empty.

For this I currently have no code it is just a form and this error only happens when the users don't use the custom add button, but instead type date in the empty text boxes and use the save record button.

Was it helpful?

Solution

I would like some further information, but to begin here are some pointers:

  1. If your problem only lies when users add a new record, you can use the form's BeforeInsert or AfterInsert event. These events are triggered as soon as the first character is entered in a field. (Access automatically inserts a new record)

    You can use those events to pre-fill some of your textfields if that is the case.

  2. Similarly, when the record changes are saved (for the complete record, all the fields, indicated by the little pencil on the left of the record turning into the arrow), the form's AfterUpdate event is triggered. You can use this event to update one value or another.

I think these 2 cases will cover your needs. If not, please supply some further information as to what exactly the changes you want, are.

Hope I helped. :)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top