Solved There is a type mismatch (1 Viewer)

hucheunghugo

New member
Local time
Tomorrow, 07:40
Joined
Apr 11, 2022
Messages
23
Code:
SeatCondition = DLookup("Condition", "Play1", "SeatID= & X" And "PlayID= & Y &")
I am not familiar with VBA
Can someone help me
It shows that there are type mismatch
 

Minty

AWF VIP
Local time
Today, 23:40
Joined
Jul 26, 2013
Messages
10,355
You aren't concatenating the variables;

SeatCondition = DLookup("Condition", "Play1", "SeatID = " & X & " And PlayID = " & Y )
 

cheekybuddha

AWF VIP
Local time
Today, 23:40
Joined
Jul 21, 2014
Messages
2,237
If you are having trouble working out string concatenation, a good trick is to use a variable which you can then inspect:
Diff:
Dim SeatCondition As Variant
Dim X As Integer, Y As Integer
Dim WhereCriteria As String

'X = ...
'Y = ...
WhereCriteria = "SeatID = " & X & " And PlayID = " & Y
Debug.Print WhereCriteria    ' Now look at the output in the Immediate Window (Ctrl+G)
SeatCondition = DLookup("Condition", "Play1", WhereCriteria)
 

Users who are viewing this thread

Top Bottom