Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Execute a query Before_Update & pass in parameter?

Status
Not open for further replies.

jgoodman00

Programmer
Jan 23, 2001
1,510
I have a number of forms which need to access the same append query. This query will be triggered before_update of the form, copying the current records data into a history table before the current modifications are saved. I need to pass the value of the PrimaryKey (RefNo) into the query, so that only one record is inserted into the history table. If only one form was going to trigger this query, it is simple to set the query criteria to [forms]... However, I need to call the query from 8 forms...


Any suggestions?? James Goodman
 
Action queries can have parameters, too. You can access the append query's QueryDef object, then assign values to its parameters using its Parameters collection. When the parameters have been set, just call the QueryDef's Execute method.

I'm a little concerned, though, about record locking getting in your way. In the BeforeUpdate event, the original record should already be locked, regardless of the form's Record Locking option. The append query may not be able to get to the data. If that's the case, you'll have to gather the fields from within the form's code and use DAO to add a record to your history table. The original values of the fields are available in each control's OldValue property. Rick Sprague
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top