Update Form Data

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

hello all,
I'm using MSAccess 2003 for a database that I create with multiple users.
One main table and form is used.
tblLog
frmPrepUser
Here is my problem.
When the database is running on all machines...
User A enters new record.
User B searches for that record using the combo box search for a record on
current form. - You can see the new entry but if you select it, it doesn't
show up on the main form. In fact, you can't even find it using the
navigation buttons. The only way you can get to the record is to close out of
Access and reopen.
I've tried adding: requery, refresh and recalc to the code to no avail..


Private Sub Combo266_AfterUpdate()
' Find the record that matches the control.
Dim rs As Object

Me.Refresh

Set rs = Me.Recordset.Clone
rs.FindFirst "[CLIENT] = '" & Me![Combo266] & "'"
If Not rs.EOF Then Me.Bookmark = rs.Bookmark
End Sub


Any ideas???
Please help!
 
Hi, Tim.

First, I'd recommend using more descriptive names for your controls for
easier programming maintenance.

If Combo266's bound column is CLIENT, and CLIENT is a text field, then set a
reference to the DAO library if it's not already used as a reference and try:

Private Sub Combo266_AfterUpdate()

On Error GoTo ErrHandler

Dim recSet As DAO.Recordset
Dim fOpenedRecSet As Boolean

Me.Requery ' Display new recs.
Set recSet = Me.RecordsetClone
fOpenedRecSet = True
recSet.FindFirst "CLIENT = '" & Me!Combo266 & "'"

If (Not (recSet.NoMatch)) Then
Me.Bookmark = recSet.Bookmark ' Jump to new rec.
End If

CleanUp:

If (fOpenedRecSet) Then
recSet.Close
fOpenedRecSet = False
End If

Set recSet = Nothing

Exit Sub

ErrHandler:

MsgBox "Error in Combo266_AfterUpdate( ) in" & vbCrLf & _
Me.Name & " form." & vbCrLf & vbCrLf & _
"Error #" & Err.Number & vbCrLf & vbCrLf & Err.Description
Err.Clear
GoTo CleanUp

End Sub

HTH.
Gunny

See http://www.QBuilt.com for all your database needs.
See http://www.Access.QBuilt.com for Microsoft Access tips and tutorials.
http://www.Access.QBuilt.com/html/expert_contributors2.html for contact info.

- - -
If my answer has helped you, please sign in and answer yes to the question
"Did this post answer your question?" at the bottom of the message, which
adds your question and the answers to the database of answers. Remember that
questions answered the quickest are often from those who have a history of
rewarding the contributors who have taken the time to answer questions
correctly.
 
Back
Top