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

Retrieve spesific record from database from dbcombo box 1

Status
Not open for further replies.

raycomp

Programmer
Jun 17, 2003
5
0
0
US
I created a form with a dbcombo3, and two text boxes textoperator and textoperatorVar and data7
with Data 7 properties:
select [Operator],[OperatorID],[OperatorVar] from Staff order by [Operator]

I need to check the condition of the field [operatorvar] to return a message depending on the condition

No problem to populate the first two fields with data7 from field [Operator] and boundcolumn[operatorid]

My problems is to find the coresponding data for the field [operatorvar]

Code when click on operator in drop down list of DBCombo3
Private Sub DBCombo3_Click(Area As Integer)
Dim sqlstring

sqlstring = "select [Operator],[OperatorID],[OperatorVar] from Staff where [OperatorID] = " & DBCombo3.BoundText

Data7.RecordSource = sqlstring
Data7.Refresh 'THIS RETURNS ERROR MESSAGE RUNTIME ERROR 3061 Too few parameters. Expected 1

Text3.Text = DBCombo3.BoundText

MsgBox DBCombo3.BoundText' IF RUN THE MESSAGE BOX RETURNS THE CORRECT OPERATOR ID AS IN DBCombo3.BoundText

Text5.Text = Data7.Recordset("OperatorVar") 'BUT THIS RETURNS THE VALUE OF THE 1ST RECORD FROM THE TABLE AND NOT THE RECORD FOR THE VALUE IN DBCombo3.BoundText

End Sub


 
Make sure that your boundcolumn is OperatorID

that means that if you use the boundtext property it wil return the value of the field OperatorID.

I think that in your case the boundcolumn is empty or operator

If that is a string and you want to compare it with a number, the compiler gives an error.

I hope that this will solve your problem.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top