Code problems

G

Guest

I have the zip combo box selecting and inserting the city in the city field
and zip inserting into the zip field when I select the city from the combo
box.

I would like to get the state text box to show the states for Indiana,
Michigan and Illinois after the zip is selected. That is where most our
business comes from. The rest of the states I will set focus and enter
manually. This is what I have so far.

‘When the user selects city or zip code from the zip drop down combo box,
selection inserts city and zip also one of the states in the code.

City State Zip Zip is a Combo Box


ComboBox Name Zip
Control Source City


Row source
SELECT ZIPCODE.* FROM ZIPCODE


After update procedure

Private Sub Zip_AfterUpdate()

If Zip >= "40000" And Zip < "50000" Then
State = "IN"
ElseIf Zip >= "50000" And Zip < "60000" Then
State = "MI"
Else
State = "IL"

End If
End Sub
Please help
 
A

Arvin Meyer

Try this (check on the true zipcode ranges:

Private Sub Zip_AfterUpdate()
Select Case Me.Zip
Case Is >= "40000" And < "50000"
State = "IN"
Case Is >= "50000" And < "60000"
State = "MI"
Case Is >= "60000" And < "70000"
State = "IL"
Case Else
State = ""
End Select
End Sub
--
Arvin Meyer, MCP, MVP
Microsoft Access
Free Access downloads:
http://www.datastrat.com
http://www.mvps.org/access
 

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

code help needed 1
Need VLOOKUP to Work Two Ways 0
Combo box help 2
Drop down boxes 1
populate form field 3
combo box help 3
Inter-Dependent Fields 9
How can I quickly change the table name in a query? 15

Top