Reputation: 147
For some reason i can't get the dlookup to function correctly i keep getting errors. The error for this is data type mismatch.
Option Compare Database
Private Sub Command131_Click()
DoCmd.SetWarnings False
If (Nz(DLookup("LetterSent1Bool", "dbo_T_Volunteers", _
"VolunteerID = '" & Me![VolunteerID] & "'"))) > 0 Then
MsgBox "ERROR ! This Volunteer has already received this Letter ,"
Else
DoCmd.OpenQuery "ProduceLettersSixToTwelve", , acReadOnly
If DCount("*", "dbo_T_SixToTwelveWeeks") > 0 Then
MsgBox "SUCCESS ! Please Open The Mail Merge Template"
Else
MsgBox "ERROR ! No Records Found"
End If
End If
End Sub
Upvotes: 0
Views: 195
Reputation: 147
Figured it out, i need to remove quotes around & Me![VolunteerID]
Option Compare Database
Private Sub Command131_Click()
DoCmd.SetWarnings False
If (Nz(DLookup("LetterSent1Bool", "dbo_T_Volunteers", _
"VolunteerID = " & Me![VolunteerID]))) > 0 Then
MsgBox "ERROR ! This Volunteer has already received this Letter ,"
Else
DoCmd.OpenQuery "ProduceLettersSixToTwelve", , acReadOnly
If DCount("*", "dbo_T_SixToTwelveWeeks") > 0 Then
MsgBox "SUCCESS ! Please Open The Mail Merge Template"
Else
MsgBox "ERROR ! No Records Found"
End If
End If
End Sub
Upvotes: 1