coding for criteria

G

Gator

I have a list box that list each letter of the alphabet. when I click on a
letter I want listbox2 to SELECT DISTINCT from a field in a table whose first
letter begins with the letter clicked, something like...

List0_Click()
List2.RowSource = "SELECT DISTINCT TreasurerDeposits.Source FROM
TreasurerDeposits WHERE....????the first letter of TreasurerDeposits.Source
equals the value selected in List0.....?????

many thanks
 
K

KARL DEWEY

Do you mean you have at least 26 fields and each is named as a letter of the
alphabet? If that is so then you need to change your data structure from
spreadsheet to a relational database structure. You can use a union query to
get there.
 
G

Gator

No...I simply have a listBox that I added values to because I don't need a
table with the letters of the alphabet as records. I just need a simple
statement to filter the list like I explained below
thanks
 
M

Mike Painter

Gator said:
I have a list box that list each letter of the alphabet. when I
click on a letter I want listbox2 to SELECT DISTINCT from a field in
a table whose first letter begins with the letter clicked, something
like...

List0_Click()
List2.RowSource = "SELECT DISTINCT TreasurerDeposits.Source FROM
TreasurerDeposits WHERE....????the first letter of
TreasurerDeposits.Source equals the value selected in List0.....?????

many thanks
WHERE yourfieldname Like "A*"
WHERE YourFieldName Like '" & YourLetter & "*'"

(if I got the quotes in the right place, but that is the idea)
 
G

Gator

I'm thinking something like...
WHERE TreasurerDeposits.Source LIKE "List0.Value()*";
but haven't nail it yet.
 
D

Douglas J. Steele

List2.RowSource = "SELECT DISTINCT TreasurerDeposits.Source " & _
"FROM TreasurerDeposits " & _
"WHERE TreasurerDeposits.Source LIKE '" & Me.List0 & "*'"

Exagerated for clarity, that last line is

"WHERE TreasurerDeposits.Source LIKE ' " & Me.List0 & " * ' "
 

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