Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

In need of a combo quick fix!!

Status
Not open for further replies.

coyote69

Technical User
Feb 19, 2002
45
US
The following is the datbound syntax used to update two text boxes on a form, they are connected to a dbcombo box with a list of zipcodes when the user selects the zipcode the city and state are automatically suppose to update well the do only after the user selects the zipcode and it get placed in the top window then if you double click next to it, It update the other fields. I tried changing this to a single click event and get and error on the txtcity.text line

Private Sub dbcZipcode_dblclick(Area As Integer)


Dim sqlstring As String
'Puts the selected ZIP, State and City into their respective boxes, moves the focus to
Dim sql As String

sql = datZipcode.RecordSource
'Get data from table

sqlstring = dbcZipcode.Text



sql = "SELECT * FROM zipcode Where Zipcode = '" + sqlstring + "' "

datZipcode.RecordSource = sql

datZipcode.Refresh




'populated associated fields, if match

txtCity.Text = datZipcode.Recordset("city")

txtState.Text = datZipcode.Recordset.Fields("State")



'reset data control

sql = "SELECT * FROM zipcode "

datZipcode.RecordSource = sql

datZipcode.Refresh




End Sub
 
you forgot the word Fields

txtCity.Text = datZipcode.Recordset.Fields("city")
 
Did not help I get and error on the datzipcode refresh
 
Try this sql statement
I suppose your zip code is a textfield.

sql="SELECT * FROM zipcode Where Zipcode ='" & sqlstring & "'"

If zipcode is a numeric field you have to leave the single quotes out of the sql
 
Does not help, if you leave out the single qute you get a syntax error. The problem is that this works fine if I leave it as a double click event. It only get an error at the datzipcode.refresh if I try to make it a single click.
 
So,
if I understand well, you have put this code in the click-event of the combobox.
If you did so, you must specify the area you click in. This comes as a parameter in the click-event of the combo

Private Sub dbcZipcode_dblclick(Area As Integer)

So your code should begin with

******************************
If Area = 2 Then
'Put the rest of your code here
End If

*******************************
The number 2 parameter that defines the area is the data in the dropdown window

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top