Macro to open record in form from another form

trackmedic

Registered User.
Local time
Today, 06:05
Joined
Aug 20, 2001
Messages
115
Hi,

I have a form that has records on employees training. I have another form where I would like to press a button and select a specific record sorted by employee. On the second form, I have a unbound combo box to pick employees names. After i pick the name, I press the macro button to open a form. How can I make the macro open the other form and go to the specific record I want? I have tried the where and typed the syntax as the help files suggested but all i get is a blank form of the original.

HELP !!!
Thanks in advance
Andre'
 
Hi Andre

Rather than using a macro try placing a cmdbutton on your form using the wizard, select open form, find specific record on my form then choose the two matching fields which would be [Your combobox name] and your field name [employee ID]

The code would look something like this:

Private Sub CmdOpenForm_Click()
On Error GoTo Err_CmdOpenForm_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "FrmYourFormName"

stLinkCriteria = "[ComboboxName]=" & Me![EmployeeID]
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_CmdOpenForm_Click:
Exit Sub

Err_CmdOpenForm_Click:
MsgBox Err.Description
Resume Exit_CmdOpenForm_Click

End Sub

Hope this helps

Hay
 

Users who are viewing this thread

Back
Top Bottom