WHERE statement in VBA

M

m stroup

Dim Divis as string
Select Case optDivision.Value
Case 1
Divis = "Govt"
Case 2
Divis = LM
Case 3
Divis = "PW"
Case Else
MsgBox "Plese select a valid Division"
Exit Sub
End Select

sHaving = " WHERE qryBilletQuery.Status = 'Filled' AND qryBilletQuery.ITF <>
0 AND qryBilletQuery.Div = """ & Divis & """"

I changed DIVIS to be a variable and thought I had the right syntax in the
Where statement above. Please advise.
 
J

Jack Leach

The syntax to the where statement appears to be correct, perhaps it's because
you forgot to enclose the LM in quotes under Case 2?

What error are you getting?

--
Jack Leach
www.tristatemachine.com

"I haven''t failed, I''ve found ten thousand ways that don''t work."
-Thomas Edison (1847-1931)
 
M

m stroup

Thanks for that Jack. Regardless of the case that is selected, however, I
get a message box asking me to input Divis.
 
M

Marshall Barton

m said:
Dim Divis as string
Select Case optDivision.Value
Case 1
Divis = "Govt"
Case 2
Divis = LM
Case 3
Divis = "PW"
Case Else
MsgBox "Plese select a valid Division"
Exit Sub
End Select

sHaving = " WHERE qryBilletQuery.Status = 'Filled' AND qryBilletQuery.ITF <>
0 AND qryBilletQuery.Div = """ & Divis & """"

I changed DIVIS to be a variable and thought I had the right syntax in the
Where statement above. Please advise.


Except for the lack of quotes around LM, it looks ok to me.
Are you sure the problem in in the Where clause?
 
J

Jack Leach

How about the Case Else statement... if the value of optDivision is not 1 2
or 3, there will be no value supplied to Divis (null), and this may prompt
such a message. Perhaps you can stop the function in that line (or redirect
to the exit procedure).

Can you verify that Divis is actually a value when it gets added to the SQL
string?

--
Jack Leach
www.tristatemachine.com

"I haven''t failed, I''ve found ten thousand ways that don''t work."
-Thomas Edison (1847-1931)
 
J

Jack Leach

Wow... apparently the coffe I had this morning did me no good whatsoever...
you already have an exit sub in there.

I'm at a bit of a loss here... hopefully someone else can see something that
I'm not? (and we know now that I'm having trouble seeing things this
morning...)

--
Jack Leach
www.tristatemachine.com

"I haven''t failed, I''ve found ten thousand ways that don''t work."
-Thomas Edison (1847-1931)
 
D

Douglas J. Steele

Exactly what is contained in sHaving? (try putting Debug.Print sHaving
statement after you assign it a value and then look in the Immediate Window
to see what's there)

How are you using sHaving?
 
M

m stroup

Thank you all. I am afraid I had a duh moment. My problem was configuration
control, having two forms, changing the code on one and using the other.

thanks for your forbearance!
 
T

tom_willpa

high quality Soccer jerseys NBA Jersey tracksuit and jackets, GHD
hairstraightener supplier from www.willpa.com

Are you a Retail businessman who bother by the purchase price? China
Cheapest TOP wholesale website can help you

we are specialize in replica sport goods manufacturing in china, we can
offer you all kinds of soccer jersey, NBA jersey,shoes and so on. they are
the best brand replica goods whih are look the same as the original goods.
excellent quality and steady supply for them. we have been marketed in Europe
and American for 3 year. all the goods we offer are AAA quality. our soccer
jersey are Thailand style. If any goods you buy from my company have problem,
we will refund or resend them again. Most of ourProducts have no minimum
order requirements,soyou can shop retail goods at wholesale prices. if you
can buy more than 300usd. We offer free shipping. The more you buy the more
discount for you.

National soccer jerseys: http://www.willpa.com
Club soccer jerseys: http://www.willpa.com
NBA Jerseys: http://www.willpa.com
T-shirt and shirt: http://www.willpa.com
Tracksuit: http://www.willpa.com
Hoody & Jackets: http://www.willpa.com
UGG boots: http://www.willpa.com
Hair style: http://www.willpa.com
shopping Index: http://www.willpa.com

EMS shipping. 7days arrive, paypal accept

want more information pls contact us or check our website: www.willpa.com
 
T

tom_willpa

high quality Soccer jerseys NBA Jersey tracksuit and jackets, GHD
hairstraightener supplier from www.willpa.com

Are you a Retail businessman who bother by the purchase price? China
Cheapest TOP wholesale website can help you

we are specialize in replica sport goods manufacturing in china, we can
offer you all kinds of soccer jersey, NBA jersey,shoes and so on. they are
the best brand replica goods whih are look the same as the original goods.
excellent quality and steady supply for them. we have been marketed in Europe
and American for 3 year. all the goods we offer are AAA quality. our soccer
jersey are Thailand style. If any goods you buy from my company have problem,
we will refund or resend them again. Most of ourProducts have no minimum
order requirements,soyou can shop retail goods at wholesale prices. if you
can buy more than 300usd. We offer free shipping. The more you buy the more
discount for you.

National soccer jerseys: http://www.willpa.com
Club soccer jerseys: http://www.willpa.com
NBA Jerseys: http://www.willpa.com
T-shirt and shirt: http://www.willpa.com
Tracksuit: http://www.willpa.com
Hoody & Jackets: http://www.willpa.com
UGG boots: http://www.willpa.com
Hair style: http://www.willpa.com
shopping Index: http://www.willpa.com

EMS shipping. 7days arrive, paypal accept

want more information pls contact us or check our website: www.willpa.com
 

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