simple Dlookup problem

  • Thread starter Thread starter Jesper F
  • Start date Start date
J

Jesper F

I have two option groups with 5 buttons. After selecting a
value in both option groups I want the code to look up a
testID in tblTests but I can't get it to work.
The first option group is called "frame1" and the
other "frame2V".

I thought the following would work:
DLookup("[testID]", "tblTests", "[testgrpID]= " &
Me.frame1 & " AND [testIDsort] = " & me.frame2 & "")

Is it a datatype problem with the variables? In the locals
windows the option group values are listed
as "Variant/long".
Thanks for any input.
 
First suggestion:

You state that the second option group is named
frame2V

but you're using frame2 in the DLookup.
 
You state that the second option group is named
frame2V
but you're using frame2 in the DLookup.

Sorry that was a typo when writing the message.
It should be:
DLookup("[testID]", "tblTests", "[testgrpID]= " &
Me.frame1 & " AND [testIDsort]= " & Me.frame2)

The expression returns NULL which confuses me.
However, Debug.Print Me.frame1 and Debug.print Me.frame2
return numbers nicely and when I simply use numbers in the
expression it works.
 
I have two option groups with 5 buttons. After selecting a
value in both option groups I want the code to look up a
testID in tblTests but I can't get it to work.
The first option group is called "frame1" and the
other "frame2V".

I thought the following would work:
DLookup("[testID]", "tblTests", "[testgrpID]= " &
Me.frame1 & " AND [testIDsort] = " & me.(frame2 & "")

Is it a datatype problem with the variables? In the locals
windows the option group values are listed
as "Variant/long".
Thanks for any input.

No problem re: datatype.
An Option Group value is a number datatype.

A different name was used (frame2V / frame2 ) and you added quotes at
the end.

DLookup("[testID]", "tblTests", "[testgrpID]= " & Me.frame1 & " AND
[testIDsort] = " & me.frame2V )
 
Could it be that frame1 and frame2 are strings?

string = NZ(DLookup("[testID]", "tblTests", "[testgrpID]= " & Me.frame1 &
""" AND [testIDsort] = """ & me.frame2 & """"),"")
 
When are you running this code? If you're getting Null as the result, then
either
(1) one of the frame objects does not have a value when you run the code
or
(2) there is no record that matches the two options' values.

--

Ken Snell
<MS ACCESS MVP>

Jesper F said:
You state that the second option group is named
frame2V
but you're using frame2 in the DLookup.

Sorry that was a typo when writing the message.
It should be:
DLookup("[testID]", "tblTests", "[testgrpID]= " &
Me.frame1 & " AND [testIDsort]= " & Me.frame2)

The expression returns NULL which confuses me.
However, Debug.Print Me.frame1 and Debug.print Me.frame2
return numbers nicely and when I simply use numbers in the
expression it works.
 
(2) there is no record that matches the two options'
values.

You're right Ken. I had switched the two parameters and
there were not records matching.
Thanks a bunch for your help both of you !
 
Back
Top