'newbie' here....I have a form that is used for searching customer name (by CustomerID) in Customer table. The control(custname) for 'search' is unbound and uses a row source - 'table/query';
Expand|Select|Wrap|Line Numbers
- SELECT Customers.CustomerID, [FirstName] & " " & [LastName] FROM Customers ORDER BY [FirstName] & "," & [LastName];
Currently I'm experiencing a problem with one of the 2 events (NotInList & AfterUpdate) associated with 'search' control (custname). I end up with two, not 1 entries of the customer in customer table.
The AfterUpdate procedure uses 'Me.RecordSetClone' after a customer is selected (or added from NotInList)....making essentially 2 of the same customer in the table.
So I need another way to 'search' for a customer and bring customer with all their data into the form.
Here is the 'AfterUpdate' event:
Expand|Select|Wrap|Line Numbers
- Private Sub custname_AfterUpdate()
- Dim rst As Object
- Set rst = Me.RecordsetClone
- rst.FindFirst "Customers.[CustomerID]=" & Me![custname]
- If Not rst.NoMatch Then
- Me.Bookmark = rst.Bookmark
- Else
- 'Not found!
- End If
Rosie
Rosie, are you still classifying yourself as a 'Newbie'? I do think you are beyond that point! Assuming [custname] is a Combo Box, try the following, revised code:
Expand|Select|Wrap|Line Numbers
- Private Sub custname_AfterUpdate()
- Dim rst As DAO.Recordset
- Set rst = Me.RecordsetClone
- rst.FindFirst "Customers.[CustomerID]=" & Me![custname].Column(0)
- If Not rst.NoMatch Then
- Me.Bookmark = rst.Bookmark
- Else
- 'Not found!
- End If