code help needed

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
 
H

Harry Betlem

I have a somewhat similar thing.
I wrote a function, containing all (Dutch) zipcodes, and their provinces.
Use the function in a Query, where the zipcode is used to 'calculate' the
province

/SNIPPET
Function fProv(ByVal t_postcode) As String
On Error GoTo ErrHandler
If Left(t_postcode, 1) = "B" Then
fProv = "Belgie" (Neighboor country)
Exit Function
ElseIf Left(t_postcode, 1) = "D" Then
fProv = "Duitsland" ( Neighboor country)
Exit Function
Else
GoTo rest
End If
rest:
Select Case Left(t_postcode, 4) (Dutch zipcode = 1234 AA)
Case Is = 7705
fProv = "Drente"
Case 7740 To 7766
fProv = "Drente"

Etc. etc. etc.
/END SNIPPET


In Mr kpe
dropped the following:
|| 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
 

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 problems 1
Need VLOOKUP to Work Two Ways 0
Combo box help 2
combo box help 3
Drop down boxes 1
populate form field 3
Inter-Dependent Fields 9
How can I quickly change the table name in a query? 15

Top