Hey all,
I'm coming over from the VB side, and I have little experience with databases so be gentle.
I've got a NASCAR pool of which I'm the "commissioner". I figured the best way for me to figure out how this database stuff works is to have a hands on project to get my feet wet. Now, I won't mention my issues with relationships and querys and all that other jazz...
I'm trying to figure out why the following lines of code work / don't work.
The fields referenced in the dlookup are as follows:
Tablename = tblCarNumbers
CarID = PrimaryKey / Long Autonumber
Car Number = String
Dim VarX as variant
...
'This works
VarX = DLookup("[carid]", "tblCarNumbers", "[car number] = Forms!frmcardriver.txtCarNumber.Text"
'This does not
VarX = DLookup("[carid]", "tblCarNumbers", "[car number] =" & Forms!frmcardriver.txtCarNumber.Text)
'Nor does this
VarX = DLookup("[carid]", "tblCarNumbers", "[car number] = 43"
'Or this
VarX = DLookup("[carid]", "tblCarNumbers", "[car number] =" & "43"
'Or even this
VarX = DLookup("[carid]", "tblCarNumbers", "[car number] =" & 43)
All except the first one gives me a type-mismatch.
Am I just a total idiot or what (don't answer that). Any thoughts?
I'm coming over from the VB side, and I have little experience with databases so be gentle.
I've got a NASCAR pool of which I'm the "commissioner". I figured the best way for me to figure out how this database stuff works is to have a hands on project to get my feet wet. Now, I won't mention my issues with relationships and querys and all that other jazz...
I'm trying to figure out why the following lines of code work / don't work.
The fields referenced in the dlookup are as follows:
Tablename = tblCarNumbers
CarID = PrimaryKey / Long Autonumber
Car Number = String
Dim VarX as variant
...
'This works
VarX = DLookup("[carid]", "tblCarNumbers", "[car number] = Forms!frmcardriver.txtCarNumber.Text"
'This does not
VarX = DLookup("[carid]", "tblCarNumbers", "[car number] =" & Forms!frmcardriver.txtCarNumber.Text)
'Nor does this
VarX = DLookup("[carid]", "tblCarNumbers", "[car number] = 43"
'Or this
VarX = DLookup("[carid]", "tblCarNumbers", "[car number] =" & "43"
'Or even this
VarX = DLookup("[carid]", "tblCarNumbers", "[car number] =" & 43)
All except the first one gives me a type-mismatch.
Am I just a total idiot or what (don't answer that). Any thoughts?