'Go to Record' button - simple task but can't get it to work

D

daneaton1982

I have created a simple list of our employees, only 32 of them. I have a combo box on our form that when clicked shows a drop down list of the last names. This part works great.
I would like it to go to the record selected..
It seems it should be a simple task..
I have played with both the macro wizard and created my own.. but nothing happens when you click on a name.
I have looked at some similar template macros to no avail.


Help please.
Dan
 
P

pcm1977

I have created a simple list of our employees, only 32 of them. I have a combo box on our form that when clicked shows a drop down list of the last names. This part works great.

I would like it to go to the record selected..

It seems it should be a simple task..

I have played with both the macro wizard and created my own.. but nothinghappens when you click on a name.

I have looked at some similar template macros to no avail.





Help please.

Dan

I assume that you have the data source of your form set to the table/query you are looking in. Place the following code in the “After Update” of your combo box. Take note that there are some areas that you will need tosubstitute your specific information with, they are in CAPITAL LETTERS.

Dim rs As Object
Set rs = Me.RecordsetClone
DoCmd.RunCommand acCmdSaveRecord ‘saves current record before doing anything
rs.FindFirst "[NAME OF FIELD IN DATABASE] = """ & Me![NAME OF COMBO BOX] & """"
If rs.NoMatch Then
Me.NAME OF COMBO BOX.SetFocus
MsgBox "Could Not Find Record", vbExclamation, "No Record Found"
Else
DoCmd.RunCommand acCmdSaveRecord ‘saves current record beforemoving to found one
Me.Bookmark = rs.Bookmark
Me.NAME OF FIELD YOU WANT TO SET THE FOCUS TO AFTER FINDING RECORD.SetFocus
End If
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top