syantax error missing query expression (1 Viewer)

hardik_088

Registered User.
Local time
Today, 11:55
Joined
May 31, 2011
Messages
82
hi guys,
I am new here and iam getting error like syntax error (missing operator )query expression in '[suggested supplier]='

Private Sub Combo31_AfterUpdate()
If (Me.Combo31.Value = "Laptops") Then
Me.Combo33.Value = Null
Me.Combo33.RowSource = "SELECT DISTINCT [suggested supplier] From " & Me.Combo31.Value & " WHERE [suggested supplier] is not null"
Me.Combo35.RowSource = ("select distinct [description ] from " & Me.Combo31 & " where [suggested supplier] = " & Me.Combo33.Value & " ")
End If
End Sub


Can you please tell me where i am wrong?
 

MarkK

bit cruncher
Local time
Today, 11:55
Joined
Mar 17, 2004
Messages
8,187
You've set the value of Combo33 to null and then included it in the construction of Combo35's RowSource, where it fails to provide a meaningful value. Try assigning Combo35's rowsource before you null Combo33.
Cheers,
Mark
 

hardik_088

Registered User.
Local time
Today, 11:55
Joined
May 31, 2011
Messages
82
hi,
i have removed me. combo33.value = null and i tried to write [suggested supplier] = 'Dell' instead bols text then its working but if i write following code is is giving same error

Private Sub Combo31_AfterUpdate()
If (Me.Combo31.Value = "Laptops") Then

Me.Combo33.RowSource = "SELECT DISTINCT [suggested supplier] From " & Me.Combo31.Value & " WHERE [suggested supplier] is not null"
Me.Combo35.RowSource = "select distinct description from " & me.combo31.value & " where [suggested supplier] = " & Me.Combo33.Value & ""

thanks
 

boblarson

Smeghead
Local time
Today, 11:55
Joined
Jan 12, 2001
Messages
32,059
Two things - by setting the Combo33 row source just before the other, it guarantees that nothing is selected and therefore it is null.

Then in the end of Combo35's row source you need to change the where part to be this:

& " where [suggested supplier] = " & Chr(34) & Me.Combo33.Value & Chr(34)
 

hardik_088

Registered User.
Local time
Today, 11:55
Joined
May 31, 2011
Messages
82
hi bob,
Actually I am using following code as per you told me i changed bold text but i am not getting exacly what you want to tell me about rowsource
of combo33

Private Sub Combo31_AfterUpdate()
If (Me.Combo31.Value = "Laptops") Then

Me.Combo33.RowSource = "SELECT DISTINCT [suggested supplier] From " & Me.Combo31.Value & " WHERE [suggested supplier] is not null"

Me.Combo35.RowSource = "select distinct description from " & Me.Combo31.Value & " where [suggested supplier] = " & Chr(34) & Me.Combo33.Value & Chr(34) & ""



ElseIf (Me.Combo31.Value = "Printers") Then
Me.Combo33.RowSource = "SELECT DISTINCT [suggested supplier]From " & Me.Combo31.Value & " WHERE [suggested supplier] is not null"
Me.Combo35.RowSource = "select distinct description from " & Me.Combo31.Value & " where [suggested supplier] = " & Chr(34) & Me.Combo33.Value & Chr(34) & ""

End If
Ens Sub


Thanks a lot
 

boblarson

Smeghead
Local time
Today, 11:55
Joined
Jan 12, 2001
Messages
32,059
Okay, the explanation is this:

you have this code:
Code:
Private Sub Combo31_AfterUpdate()
If (Me.Combo31.Value = "Laptops") Then

Me.Combo33.RowSource = "SELECT DISTINCT [suggested supplier] From " & Me.Combo31.Value & " WHERE [suggested supplier] is not null"

Me.Combo35.RowSource = "select distinct description from " & Me.Combo31.Value & " where [B][suggested supplier] = " & Chr(34) & Me.Combo33.Value & Chr(34) & ""[/B]

And in that code you have Me.Combo33.RowSource = ....etc. and right the next line you are using Chr(34) & Me.Combo33.Value & Chr(34) (and by the way you don't need the & "" at the end of it - you should get rid of it as it is extra fluff that is not needed).

So, you are setting combo33's row source which will make the value NULL. There won't be a value unless it is selected. So checking for the value in the next line won't work because it is null. Nothing has been selected.
 

hardik_088

Registered User.
Local time
Today, 11:55
Joined
May 31, 2011
Messages
82
hi bob, now i got it but if i click on dropdown box of combo35 to select item and i want that whatever value is in combo33 it should be selected as a value of combo33 what i should do?

i tried on click event of combo35
me.combo33.selected = true

but is did not work
Thanks
 

Users who are viewing this thread

Top Bottom