Open new form with selected record and browse others

M

Mesa

Hello everyone, this is my problem. I have a combobox that has names
of people in my records. I can select any name and it will load the
related record in my form.

I want to be able to click on a button and load a different form but be
on the same record. I can do this with the wizard but I cannot scroll
other records. How can I code this and still view other records.





Private Sub Personnel_Button_Click()
On Error GoTo Err_Personnel_Button_Click

Dim stDocName As String
Dim stLinkCriteria As String

DoCmd.Close
stDocName = "Personnel"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_Personnel_Button_Click:
Exit Sub

Err_Personnel_Button_Click:
MsgBox Err.Description
Resume Exit_Personnel_Button_Click

End Sub

Currently I have it coded to close the previous form and open a form
"Personnel" in its place. Thanks for the help.
 
A

Allen Browne

To browse to other records, turn the filter off.

You can do that by releasing the Filter button on the toolbar.
Or you can do it programmatically by clicking a button when ready to browse:
Me.FilterOn = False

The alternative is to OpenForm without the stLinkCriteria. Instead FindFirst
in the RecordsetClone of the form, and set its Bookmark.
 
M

Mesa

Well I tried and maybe I didnt know how to apply it, but it didnt work.
Thanks for the reply though.
 
A

Allen Browne

I gave you 3 answers.

You will be able to get one of those working if you try.
 
M

Mesa

Im sorry, I just found out what I did wrong and the coding you said
worked perfectly. Trust me, I was not being lazy, just overlooking a
minor detail. Your help I very appreciated, thankyou.
 
M

Mesa

Well, there is one last thing, I cant find out how to release the
filter when I change records via scroll mouse. Is there a way to use
the "Me.FilterOn = False" so that when I move out of the record it
turns off the filter. I embedded the code with the buttons but I dont
want to have to push the next button in order to scroll records because
thats a really nice feature.
 
M

Mesa

NVM, I got it, the coding is below to anyone who would like to know.


Private Sub Form_MouseWheel(ByVal Page As Boolean, ByVal Count As Long)

Me.FilterOn = False

End Sub

This will allow my mouse wheel to deactivate the filter. Thanks to all
the great programers out there who helped.
 

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

Similar Threads


Top