Open a form for specific record.

G

Guest

I did it many times but now I forgot it and cannot open a form for a specific
value.
There was a method that create the following code automatically. We can
match the values and even determine the picture or text on the toggle button
with that method . Please help.

Private Sub Command19_Click()
On Error GoTo Err_Command19_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Form"

stLinkCriteria = "[PARTNO]=" & "'" & Me![Combo5] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_Command19_Click:
Exit Sub

Err_Command19_Click:
MsgBox Err.DESCRIPTION
Resume Exit_Command19_Click

End Sub
 
G

Guest

If the Part No field is number you should try this
stLinkCriteria = "[PARTNO]=" & Me![Combo5]
DoCmd.OpenForm stDocName, , , stLinkCriteria
===================================
If the Part No field is text you should try this
stLinkCriteria = "[PARTNO]= '" & Me![Combo5] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria
===================================
If the Part No, is not the first column in the combo, then you should
specify the column number
stLinkCriteria = "[PARTNO]= '" & Me![Combo5].column(1) & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria
'the column number start with 0
 
G

Guest

One more thing, if the form name is "form", it a word that bean used by
access, you better change the name, it can cause to some problems
 
G

Guest

Thank you but threre is a tool for dummies(I used to know and use many times,
but I forgot). Not a code. It creates that code. I will go to mad.

Ofer said:
One more thing, if the form name is "form", it a word that bean used by
access, you better change the name, it can cause to some problems
--
I hope that helped
Good luck


AhmtDY said:
I did it many times but now I forgot it and cannot open a form for a specific
value.
There was a method that create the following code automatically. We can
match the values and even determine the picture or text on the toggle button
with that method . Please help.

Private Sub Command19_Click()
On Error GoTo Err_Command19_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Form"

stLinkCriteria = "[PARTNO]=" & "'" & Me![Combo5] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_Command19_Click:
Exit Sub

Err_Command19_Click:
MsgBox Err.DESCRIPTION
Resume Exit_Command19_Click

End Sub
 

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