help with a sql query

R

Rich

Hello,

I am building a small application that contains addresses. I have a table
with the names and 2 letter abbreviation of all 50 states. When a 2 letter
state abbrev. is entered, I want to verify it against the state table. I'm
not sure how to approach this.

Option 1. When this field gets the focus, user should enter the first
letter of the state. Those states that then match the condition are then
displayed in the drop down box. Question, should this field be a drop down
or combo box? (i.e. Enter the letter 'A' and execute the query:
"select state_abbrev from tblStates
where StateAbbrev is like value_entered"

So, if user enters "A", state abbreviations for every state that starts with
"A" should populate the field and the user can select the correct state
abbreviatoin.

If user enters a letter such as "Q" for which there is no state, a message
box could be displayed with appropriate error.

Option 2: When state field gets the focus, all 50 states appear in the box
and user can select the correct abbreviation. I guess this might be the
better option.

Can anyone help me with the code? Should the code execute when the box gets
the focus or when the users hits the drop down arrow?

TIA,
Rich
 
K

Klatuu

Create a Combo box with your state table as the row source. Use the field
that has the state abbreviation as the bound column. Then set the Auto Expand
property to Yes. Say you type "O" as the first letter, it will highlight
the first state that starts with O
 
R

Rich

Thank you much!!

Rich



Klatuu said:
Create a Combo box with your state table as the row source. Use the field
that has the state abbreviation as the bound column. Then set the Auto
Expand
property to Yes. Say you type "O" as the first letter, it will highlight
the first state that starts with O
 

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