stLinkCriteria with two times on one button

Highnz

Registered User.
Local time
Today, 08:23
Joined
Aug 23, 2005
Messages
16
stLinkCriteria two times on one button

hi,
i have a problem with the command stLinkCriteria.
i want to open a form and filter it by matching data in two specific datafields.
now my button code is loocking so:


Private Sub F_Probendaten_subform_Open_Analysendaten_Click()
On Error GoTo Err_F_Probendaten_subform_Open_Analysendaten_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "F_Analysedaten"

stLinkCriteria = "[Auftrags-Nr]=" & "'" & Me![Auftrags-Nr] & "'" And "[Proben-Nr]=" & "'" & Me![Proben-Nr] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_F_Probendaten_subform_Open_Analysen:
Exit Sub

Err_F_Probendaten_subform_Open_Analysendaten_Click:
MsgBox Err.Description
Resume Exit_F_Probendaten_subform_Open_Analysen

End Sub



when i click on the button, access displays a message box with this text: Type dismatch

i thing there is a failure in my syntax. but i don't know how to do this running.
i am using ms access 2002/xp and ms vba 6.3
thanks
 
Last edited:
If the two fields are Text fields then...
Code:
stLinkCriteria = "[Auftrags-Nr]= '" & Me![Auftrags-Nr] & "' And [Proben-Nr]= '" & Me![Proben-Nr] & "'"
and...
Code:
stLinkCriteria = "[Auftrags-Nr]= " & Me![Auftrags-Nr] & " And [Proben-Nr]= " & Me![Proben-Nr]
...if they are numeric fields. The original code had an extra " or two. :)
 
its working :D
thank you for the solution RuralGuy
 

Users who are viewing this thread

Back
Top Bottom