Hi all,
I have this code run through a macro to open a project:
Code:
Function OpenAProject()
Dim p
p = InputBox("Please enter Project Number", "Open a Project")
If p > "" Then
p = UCase(p)
If DLookup("[Project Number]", "Projects", "[Project Number] = '" & p & "'") = p Then
DoCmd.OpenForm "Projects", , , "[Project Number] = '" & p & "'"
Else
MsgBox "Sorry - " & p & " isn't a valid project number", vbExclamation, "CPAMS"
End If
End If
End Function
I have a table called Projects, the "UID" is the Project Number column, and also have a form called Projects. The above code produces a box to prompt for the Project number and then to open that record up. However im getting an error:
"Data type mismatch in criteria expression"
and the following line is highlighted as the problem:
Code:
If DLookup("[Project Number]", "Projects", "[Project Number] = '" & p & "'") = p Then
I'm perplexed as I'm sure I have used this code before in other projects. If anyone has any pointers or could assist me that would be great.
Thanks
Luke