Combo Box Query in VBA

  • Thread starter Thread starter Guest
  • Start date Start date
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
 
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;"
 
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
 
Hi Ofer,

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

Thanks,

Bonnie
 
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
 
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
 
Back
Top