T
Toffee
I have a form that includes an unbound control used for
searching records. When the form loads, this control
receives the focus first. If I type in a search number
for a record before all the records are loaded, the form
will display the data from that record but any data I
enter will appear to not be accepted. The problem is that
it will actually be entered in the table under the
previous record in the form which causes huge data error
problems. I discovered this by looking at the form record
by the navigation buttons and realizing it was one number
off. I also found that if I index one record ahead using
the forward navigation button and then use the unbound
control to search for a record before all records are
loaded, it is off by two records.
If I wait until the number of records is displayed
(appears as "of xxxx" to the right of the navigation
buttons on the bottom of the form), this problem never
happens. If I enter a search number prior to that, it
always does. Is there a way I can prevent a user from
entering data into a control or from changing records
until all records are loaded for a form? By placing beeps
in the code, it appears as if the form and control events
are already completed and all items are loaded and then
you still have a couple seconds where this error can take
place prior to all records being loaded. I don't know if
this has to do with the recordset cloning or what. If so,
maybe there is a better option to prevent this problem.
The code for the unbound control is as follows...
Private Sub Combo_FindCustomer_AfterUpdate()
'Find the record that matches the customer number
Dim rs As Object
Set rs = Me.Recordset.Clone
rs.FindFirst "[CustomerNumber] = '" & Me!
[Combo_FindCustomer] & "'"
Me.Bookmark = rs.Bookmark
End Sub
searching records. When the form loads, this control
receives the focus first. If I type in a search number
for a record before all the records are loaded, the form
will display the data from that record but any data I
enter will appear to not be accepted. The problem is that
it will actually be entered in the table under the
previous record in the form which causes huge data error
problems. I discovered this by looking at the form record
by the navigation buttons and realizing it was one number
off. I also found that if I index one record ahead using
the forward navigation button and then use the unbound
control to search for a record before all records are
loaded, it is off by two records.
If I wait until the number of records is displayed
(appears as "of xxxx" to the right of the navigation
buttons on the bottom of the form), this problem never
happens. If I enter a search number prior to that, it
always does. Is there a way I can prevent a user from
entering data into a control or from changing records
until all records are loaded for a form? By placing beeps
in the code, it appears as if the form and control events
are already completed and all items are loaded and then
you still have a couple seconds where this error can take
place prior to all records being loaded. I don't know if
this has to do with the recordset cloning or what. If so,
maybe there is a better option to prevent this problem.
The code for the unbound control is as follows...
Private Sub Combo_FindCustomer_AfterUpdate()
'Find the record that matches the customer number
Dim rs As Object
Set rs = Me.Recordset.Clone
rs.FindFirst "[CustomerNumber] = '" & Me!
[Combo_FindCustomer] & "'"
Me.Bookmark = rs.Bookmark
End Sub