joshld
asked on
Dlookup Access 2007
What is wrong with this? It keeps telling me that the dlookup is wrong.
If LabelModelNumber.Caption = "" Then ExhaustStack.Value = "" Else ExhaustStack.Value = DLookup("ExhaustStack", "WasherModules", "ModelNumber ='" & LabelModelNumber.Caption & "'")
ASKER
it give me a run-time error: object required.
what is Chr(34)? is that "'"?
what is Chr(34)? is that "'"?
Chr(34) is a double quote ... used for clarity in posting.
OK ... what exactly is 'LabelModelNumber.Caption' ?
mx
OK ... what exactly is 'LabelModelNumber.Caption'
mx
ASKER
labelmodelnumber.caption would be the label of a model number I have on the form. In this case the caption is "W3X5X8-304-NH-H". I want it to match the model number from the table.
Well ... I don' think you can really refer to the label caption property. You need to get that value in a text box instead.
Lets try this:
Dim sCap as String
sCap = Me.LabelModelNumber.Captio n
If LabelModelNumber.Caption = "" Then
ExhaustStack.Value = ""
Else ExhaustStack.Value = DLookup("ExhaustStack", "WasherModules", "[ModelNumber] = " & Chr(34) & sCap & Chr(34))
End If
mx
Lets try this:
Dim sCap as String
sCap = Me.LabelModelNumber.Captio
If LabelModelNumber.Caption = "" Then
ExhaustStack.Value = ""
Else ExhaustStack.Value = DLookup("ExhaustStack", "WasherModules", "[ModelNumber] = " & Chr(34) & sCap & Chr(34))
End If
mx
Sorry .. ignore " You need to get that value in a text box instead." of the last post.
mx
mx
ASKER
I still get the same error with this code:
LabelModelNumber.Caption = "" Then ExhaustStack.Value = "" Else ExhaustStack.Value = DLookup("ExhaustStack", "WasherModules", "[ModelNumber] = " & Chr(34) & txtModelNumber.value & Chr(34))
What happens if you try this hard coded as a test:
IF LabelModelNumber.Caption = "" Then
ExhaustStack.Value = ""
Else ExhaustStack.Value = DLookup("ExhaustStack", "WasherModules", "[ModelNumber] = " & Chr(34) & "W3X5X8-304-NH-H" & Chr(34))
End If
mx
IF LabelModelNumber.Caption = "" Then
ExhaustStack.Value = ""
Else ExhaustStack.Value = DLookup("ExhaustStack", "WasherModules", "[ModelNumber] = " & Chr(34) & "W3X5X8-304-NH-H" & Chr(34))
End If
mx
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
This is the error code.
errorcode.bmp
errorcode.bmp
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Sorry, I'm stupid when it comes following the names I created. I needed to put "txt" in front of ExhaustStack.value.
Thanks guys.
Thanks guys.
"Sorry, I'm stupid when it comes following the names I created. I needed to put "txt" in front of ExhaustStack.value."
you are welcome.
mx
you are welcome.
mx
If LabelModelNumber.Caption = "" Then ExhaustStack.Value = "" Else ExhaustStack.Value = DLookup("ExhaustStack", "WasherModules", "[ModelNumber] = " & Chr(34) & LabelModelNumber.Caption & Chr(34))
mx