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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

syntax error in sql query on after update event ?/

Status
Not open for further replies.

miscluce

MIS
Oct 4, 2007
149
US
I have a syntax error in my SQL. Can someone help me with this?
I think I need to use single quotes because its a TEXT datatype but I dont know how to change it?

Private Sub cboMake_AfterUpdate()
Me.cboModel.RowSource = "SELECT fldModel FROM tblCar WHERE fldMake = " & Me.cboMake.Column(1) & " "
End Sub
 



hi,
Code:
WHERE fldMake = '" & Me.cboMake.Column(1) & "' "


Skip,

[glasses] When a diminutive clarvoyant had disappeared from detention, headlines read...
Small Medium at Large[tongue]
 
thanks. but for some reason I get no values in my second combo box. can someone help me with this?

I have a table(tblCar) and 2 combo boxes)cbomake and cboModel)

table car has five fields(ID, make, model, price)

cboMake gets populated by this:

Private Sub Form_Load()
Me.cboMake.RowSource = "SELECT DISTINCT fldMake FROM tblCar"
End Sub

and I am trying to populate cboModel by this but I get nothing:

Private Sub cboMake_AfterUpdate()
Me.cboModel.RowSource = "SELECT fldModel FROM tblCar WHERE fldMake = '" & Me.cboMake.Column(1) & "'"
End Sub

 
How about...
Code:
Private Sub cboMake_AfterUpdate()
Me.cboModel.RowSource = "SELECT fldModel FROM tblCar WHERE fldMake = '" & _
     Me.cboMake.Column(1) & "'"
[COLOR=red]Me.cboModel.Requery[/color]
End Sub


Randy
 
Since my bound property for cboMake was 1 ,

I fixed it doing this..

Me.cboModel.RowSource = "SELECT fldModel FROM tblCar WHERE fldMake = '" & Me.cboMake & "'"
Me.cboModel.Requery

why it dont work with column 1, I dont know?

I know columns start at 0 and Make is in column(1).
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top