DAZarlengo
New Member
- Joined
- Oct 18, 2003
- Messages
- 11
We use a form to input a very long record. Several of the fields involve a lot of typing. The problem is that if anything interrupts the input process (such as hitting escape, a power glitch, etc.), the entire record is lost, since Access only saves a record when you finish the last field.
We would like the record to be automatically saved numerous times along the way, without advancing to the next record.
I found one method that works perfectly.
* Open the form in design mode
* Right-click each text box we want to save at
* Click Properties
* Click the box for “On Got Focus”
* Click the down arrow and select [Event Procedure]
* Click the little box with 3 dots
This creates a bit of VB code attached to the form that looks like:
Private Sub MyControlName_GotFocus()
End Sub
I insert one more line, to end up with this:
Private Sub MyControlName_GotFocus()
RunCommand acCmdSaveRecord
End Sub
This works perfectly. What I don’t like about it is that each control requires a different sub, with the control name as part of the Sub statement. What I would like to do is just write one Sub, and have the “On Got Focus” from any text box execute it.
To sum up the problem, how do I make any of the event procedures, such as "On Got Focus," call a user-written Sub?
We would like the record to be automatically saved numerous times along the way, without advancing to the next record.
I found one method that works perfectly.
* Open the form in design mode
* Right-click each text box we want to save at
* Click Properties
* Click the box for “On Got Focus”
* Click the down arrow and select [Event Procedure]
* Click the little box with 3 dots
This creates a bit of VB code attached to the form that looks like:
Private Sub MyControlName_GotFocus()
End Sub
I insert one more line, to end up with this:
Private Sub MyControlName_GotFocus()
RunCommand acCmdSaveRecord
End Sub
This works perfectly. What I don’t like about it is that each control requires a different sub, with the control name as part of the Sub statement. What I would like to do is just write one Sub, and have the “On Got Focus” from any text box execute it.
To sum up the problem, how do I make any of the event procedures, such as "On Got Focus," call a user-written Sub?