stLinkCriteria (1 Viewer)

*Pete*

Registered User.
Local time
Today, 18:09
Joined
Jul 17, 2006
Messages
40
Hi, I can't seem to combine these to one button. I need to open a form based on the values in two fields.

Seperatly they work, when i try to combine them using the AND function it comes up with the error data mismatch.

Code:
Private Sub cmdEvidenceSummary_Click()
On Error GoTo Err_cmdEvidenceSummary_Click

    Dim stDocName As String
    Dim stLinkCriteria As String

    stDocName = "F_EvidenceSummary"
    
    stLinkCriteria =  "[Unit]=" & Me![Unit]
    
    DoCmd.OpenForm stDocName, , , stLinkCriteria


Exit_cmdEvidenceSummary_Click:
    Exit Sub

Err_cmdEvidenceSummary_Click:
    MsgBox Err.Description
    Resume Exit_cmdEvidenceSummary_Click
    
End Sub


Code:
Private Sub Command28_Click()
On Error GoTo Err_Command28_Click

    Dim stDocName As String
    Dim stLinkCriteria As String

    stDocName = "F_EvidenceSummary"
    
    stLinkCriteria = "[Identifier]=" & Me![Candidate]
    DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_Command28_Click:
    Exit Sub

Err_Command28_Click:
    MsgBox Err.Description
    Resume Exit_Command28_Click
    
End Sub

Any advice?

this is what i have but with the error

Code:
Private Sub cmdEvidenceSummary_Click()
On Error GoTo Err_cmdEvidenceSummary_Click

    Dim stDocName As String
    Dim stLinkCriteria As String

    stDocName = "F_EvidenceSummary"
    
    stLinkCriteria = "[Identifier]=" & Me![Candidate] And "[Unit]=" & Me![Unit]
    
    DoCmd.OpenForm stDocName, , , stLinkCriteria


Exit_cmdEvidenceSummary_Click:
    Exit Sub

Err_cmdEvidenceSummary_Click:
    MsgBox Err.Description
    Resume Exit_cmdEvidenceSummary_Click
    
End Sub
 

KeithG

AWF VIP
Local time
Today, 10:09
Joined
Mar 23, 2006
Messages
2,592
try this

stLinkCriteria = "[Identifier]=" & Me![Candidate] & " And [Unit]=" & Me![Unit]
 

Bat17

Registered User.
Local time
Today, 18:09
Joined
Sep 24, 2004
Messages
1,687
try
stLinkCriteria = "[Identifier]=" & Me![Candidate] & " And [Unit]=" & Me![Unit]
though if the criteria are text then they will need wrapping in quotes

Peter
 

*Pete*

Registered User.
Local time
Today, 18:09
Joined
Jul 17, 2006
Messages
40
Thanks for the help, that worked perfectly.
 

Users who are viewing this thread

Top Bottom