Solola
Board Regular
- Joined
- Sep 23, 2003
- Messages
- 73
I have a data-entry form (frmTDMEntry) into which the user enters about 15 fields of data into the table t_tdm. When the user tabs to the next blank, new record, I want Access to run an update query on the t_tdm.
Based on the fields that were entered in record #1, I have an update query (q_SIP_fields_update) that will update 11 additional fields for that record on t_tdm. I want this query to trigger automatically when a new record is created, so that the first record is updated. (I need this to happen, b/c my table has validation that requires that one of these 11 fields be unique. If it's not updated before a new record is created, the new record errors out - b/c both record #1 and record #2 have blanks in that field, and they're not unique).
I tried this code on the form's oncurrent method, but I get an run-time 3078 error when I first open my form - "Microsoft cannot find the input table or query." Also, I'm not sure how to prevent this query from running when I FIRST open the form for entering the first new record - I want it to update the first record only if I'm trying to then enter a second new record:
Private Sub Form_Current()
If Me.NewRecord Then
DoCmd.SetWarnings False
CurrentDb.Execute q_SIP_fields_update
DoCmd.SetWarnings True
End If
End Sub
I guess really, what I'd like it to do is trigger this update query immediately after the first record is saved to the table, regardless of whether or not I also enter a 2nd new record. But how do I do that? The data-entry person may be entering only 1 record, or 10 records at a time and will want to tab from one record to the next new one...
Please help?
Based on the fields that were entered in record #1, I have an update query (q_SIP_fields_update) that will update 11 additional fields for that record on t_tdm. I want this query to trigger automatically when a new record is created, so that the first record is updated. (I need this to happen, b/c my table has validation that requires that one of these 11 fields be unique. If it's not updated before a new record is created, the new record errors out - b/c both record #1 and record #2 have blanks in that field, and they're not unique).
I tried this code on the form's oncurrent method, but I get an run-time 3078 error when I first open my form - "Microsoft cannot find the input table or query." Also, I'm not sure how to prevent this query from running when I FIRST open the form for entering the first new record - I want it to update the first record only if I'm trying to then enter a second new record:
Private Sub Form_Current()
If Me.NewRecord Then
DoCmd.SetWarnings False
CurrentDb.Execute q_SIP_fields_update
DoCmd.SetWarnings True
End If
End Sub
I guess really, what I'd like it to do is trigger this update query immediately after the first record is saved to the table, regardless of whether or not I also enter a 2nd new record. But how do I do that? The data-entry person may be entering only 1 record, or 10 records at a time and will want to tab from one record to the next new one...
Please help?