Combo Box Query in VBA

G

Guest

I'm having trouble with the multiple criteria in this code. It isn't
returning the record I know is there.

Me.PWIDTH6.RowSource = "Select distinct parts.lheight " & _
"FROM parts " & _
"WHERE parts.ItemDesc = '" & descrip.Value & "' " & _
"AND parts.pwidth = '" & Text2.Value & "' " & _
"ORDER BY parts.lheight;"

Can anyone help me?

Thanks in advance,

Bonnie
 
G

Guest

Is the field "pwidth" type is numeric?
If so you need to drop the single quote, that you use only for text fields

Me.PWIDTH6.RowSource = "Select distinct parts.lheight " & _
"FROM parts " & _
" WHERE parts.ItemDesc = '" & descrip.Value & "' " & _
" AND parts.pwidth = " & Text2.Value & " " & _
" ORDER BY parts.lheight;"
 
G

Guest

Thanks Ofer - you have helped me before also. I appreciate your taking the
time. It is numeric and I'm sure that's it.

Thanks again.

Bonnie
 
G

Guest

Hi Ofer,

That wasn't the problem, I tried it both ways and get the same behaviour.
Any other ideas?

Thanks,

Bonnie
 
B

Bob Quintal

Hi Ofer,

That wasn't the problem, I tried it both ways and get the same
behaviour. Any other ideas?

Thanks,

Bonnie

Specify the form on which your controls reside, either by using Me!
or Forms!formname!
" WHERE parts.ItemDesc = '" & Me!descrip.Value & "' " & _
" AND parts.pwidth = " & Me!Text2.Value & " " & _


Q
 
G

Guest

Thanks Bob, I'll play with that but there are two other combo boxes I am
using with the same syntax (one criteria) that are working fine.

Bonnie
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top