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

Syntax for setting form recordsource 1

Status
Not open for further replies.
May 5, 2002
79
US
All,

Have the following code:

Private Sub cboBoxNum_AfterUpdate()
Dim strSQLSF As String
Dim TowerX As Integer
Dim BoxX As Integer

TowerX = Me.cboTower.Value
BoxX = Me.cboBoxNum.Value

strSQLSF = " SELECT * FROM tblBoxSlot "
strSQLSF = strSQLSF & " WHERE tblBoxSlot.Tower = TowerX And "
strSQLSF = strSQLSF & " tblBoxSlot.BoxNum = BoxX;"

Me.RecordSource = strSQLSF

Me.Requery

End Sub

When the event runs the sqlstring seems to be correct however when the code sets the record source the form is displaying a parameter prompt for TowerX and BoxX. Any ideas?

Many thanks.
 
You need
Code:
strSQLSF = " SELECT * FROM tblBoxSlot "
strSQLSF = strSQLSF & " WHERE tblBoxSlot.Tower = " & TowerX & " And "
strSQLSF = strSQLSF & " tblBoxSlot.BoxNum = " & BoxX & ";"


[small]On two occasions I have been asked, "Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?" I am not able rightly to apprehend the kind of confusion of ideas that could provoke such a question. (Charles Babbage)[/small]
 
Thanks Golom. Worked perfectly. I had tried some syntax using various qoute combos (even researching some) and get confused on doubles for strings, # for dates, and nothing for Integers. So I was using nothing for the integer assumeing it was resolving the variable to type. I've learned something here. Thank you.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top