Hello Access wizards (no pun intended!),
Version is Access 2007.
Unbelievably, I can't seem to find a solution to this problem. Several sites had good information that seemed to come close, but I couldn't get any of the VBA variations to work.
I have a simple find combo box that lists records by last name then first name. The problem is that if more than one user in the DB has the same last name, the code will only return the first name on the list with that last name.
Here is the code in the AfterUpdate event:
Looking at the code, it is understandable why it will only return the first instance of identical last names. But I have tried every combination I can think of for the last few days to make it capable of multiple criteria, and all either retun errors or just plain fails to run.
I realize that I can just use a wizard and be done with it, but the wizard-created macro seems to run slower and besides, I can't increase my VBA knowledge if I have wizards do everything and never look under the hood. Speaking of wizards, I did use an 03 version to have a wizard build what I need since the earlier wizards use VBA. I then lifted the code from the IDE and put it in the 07 version (after entering the row source), but it also failed to run. Came back with a 'type mismatch' error. Here is that code:
I am not just looking for working code here, but could someone please give me a Reader's Digest explanation of what I am doing wrong?
Thanks.
Version is Access 2007.
Unbelievably, I can't seem to find a solution to this problem. Several sites had good information that seemed to come close, but I couldn't get any of the VBA variations to work.
I have a simple find combo box that lists records by last name then first name. The problem is that if more than one user in the DB has the same last name, the code will only return the first name on the list with that last name.
Here is the code in the AfterUpdate event:
Code:
Dim rs As Object
Set rs = Me.Recordset.Clone
rs.FindFirst "[Last] = '" & Me![cmbFindRecord] & "'"
If Not rs.EOF Then Me.Bookmark = rs.Bookmark
Looking at the code, it is understandable why it will only return the first instance of identical last names. But I have tried every combination I can think of for the last few days to make it capable of multiple criteria, and all either retun errors or just plain fails to run.
I realize that I can just use a wizard and be done with it, but the wizard-created macro seems to run slower and besides, I can't increase my VBA knowledge if I have wizards do everything and never look under the hood. Speaking of wizards, I did use an 03 version to have a wizard build what I need since the earlier wizards use VBA. I then lifted the code from the IDE and put it in the 07 version (after entering the row source), but it also failed to run. Came back with a 'type mismatch' error. Here is that code:
Code:
Dim rs As Object
Set rs = Me.Recordset.Clone
rs.FindFirst "[PersonnelID] = " & Str(Nz(Me![cmbFindRecord], 0))
If Not rs.EOF Then Me.Bookmark = rs.Bookmark
I am not just looking for working code here, but could someone please give me a Reader's Digest explanation of what I am doing wrong?
Thanks.