HI Can anyone tell me where is the error in this statement Please.
DLookup("[NT]", "tblAssignment", "[NT] = " & Forms!MainMenu!WinUserName & "
Thank you
Z
Thank you Maq But now I am getting a Type Mismatch error. It is highlighting the first row:
If DLookup("[NT]", "tblAssignment", "[NT] = '" & Forms!MainMenu!WinUserName & "'" Then
Me.Start_Record = Me![tblAssignment].Form![Start_Record]
Else
msgbox "No work assign For You"
End If
WinUserName is a textbox.
Sorry, I have to disagree. If NT is a text field then it needs the quotes around it. However, if NT is a number then Poteen is correct and putting the quotes around it will hurt the results.
But, an added note. I am using Access97. It's possible that the syntax has changed with Access2000 and beyond and what Poteen said may be correct for those versions. I know a lot of the syntax did change with the Access2000 upgrade.
Hi By doing it your way I am getting a Runtime Error 64479...Which States The eexpression you enter as a query parameter product this error : 'The object doesn't contain the automation object "ZRAZZ"
And Then I tried Mar's way and it skips over the statement and think that it is false when instead it is true.
I do not know what to do.
I tried
If DLookup("[NT]", "tblAssignment", "[NT] = " & Me!WinUserName) Then
OR
If DLookup("[NT]", "tblAssignment", "[NT] = '" & Me.WinUserName & "'" Then
This statements is the one that makes it think its false when it is true.
What exactly is the "NT" field? Is it a text field? If so, why are you using it as a boolean? If it is a boolean then don't try to match it to a text field on your form.
If all you need is to determine whether or not a record exists where NT = the field on your form, then I would recommend using the DCount function instead.
If DCount("[NT]", "tblAssignment", "[NT] = '" & Me!WinUserName & "'" > 0 Then
or if you prefer using the Dlookup function then:
If Not(IsNull(DLookup("[NT]", "tblAssignment", "[NT] = '" & Me!WinUserName & "'")) Then
And again the examples above assume that "NT" is a text field.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.