coding for criteria

  • Thread starter Thread starter Gator
  • Start date Start date
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
 
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.
 
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
 
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)
 
I'm thinking something like...
WHERE TreasurerDeposits.Source LIKE "List0.Value()*";
but haven't nail it yet.
 
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 & " * ' "
 
Back
Top