Question about an SQL statement

  • Thread starter Afrosheen via AccessMonster.com
  • Start date
A

Afrosheen via AccessMonster.com

I have an SQL statement that is way to long.
bd="days"
bn="nights"
ds="day shift"
and so on.

stwhere1 = "SELECT [shift],[lname],[fname],[locat1]" & _
" FROM [tbl_Roster]" & _
" WHERE [shift] = '" & bd & "' or [shift]='" & bn & "' or [shift]
='" & ds & "' or [shift]='" & dn & "'or [shift]='" & aft & "'"

The above WHERE is on one line and it works.

I was wondering if I could use something like this to make it more readable?

" WHERE [shift] = '" & bd & and & bn & and & ds & and & dn & and & aft & "'"

Thanks for your help. It is much appreciated.
 
D

Douglas J. Steele

" WHERE [shift] IN ('" & bd & "', '" & bn & "', '" & ds & "', '" & dn & "',
'"& aft & "')"
 
S

Stefan Hoffmann

hi,

" WHERE [shift] = '"& bd& and& bn& and& ds& and& dn& and& aft& "'"

Thanks for your help. It is much appreciated.
Maybe you have an normalization issue. Do you need to query all shifts
or do your shifts have something in common?

I would consider using a Shift table.

mfG
--> stefan <--
 
A

Afrosheen via AccessMonster.com

Thanks for the quick reply and help again Doug. It work like I wanted it to.

" WHERE [shift] IN ('" & bd & "', '" & bn & "', '" & ds & "', '" & dn & "', '"& aft & "')"
I have an SQL statement that is way to long.
bd="days"
[quoted text clipped - 17 lines]
Thanks for your help. It is much appreciated.
 

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

Similar Threads

VBA question confused 3
Programming Question 3
SLQ in VBA 6
filtering 2
statements in a filter 1
statements in a filter 2
Cumulative formula for word table 0
Mutli Rosters within Division 2

Top