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!

pass integer to sql stmt.

Status
Not open for further replies.

74maiden

Programmer
Dec 18, 2002
9
IE

Hi all,

I´m having a problem with passing a bound value ´value1´ from a subReport ´subRep1´ into a SQL statement.

Find my code below.......

==========================================
Dim varRecords As Variant
Dim dbs As Database
Dim recSet As DAO.Recordset
Dim strQuerySQL As String
Dim inVar As Int

Set dbs = CurrentDb
inVar = [Reports]![Rep1]![subRep1].[Report]![value1]
strQuerySQL = "SELECT * FROM Table1"
strQuerySQL = strQuerySQL & "WHERE (Table1.DRLID) = inVar"
strQuerySQL = strQuerySQL & "ORDER BY Table1.DRLID;"
Set recSet = dbs.OpenRecordset(strQuerySQL, dbOpenDynaset)
recSet.FindFirst inVar

=====================================
The field inVar gets populated correctly, but therefore the recSet RecordSet doesn´t work.
Also, is the syntax for the line....
recSet.FinFirst invar ......correct?

Your probably saying why not use the Sekk method, but it doesn´t seem to work with linked tables!!

Thankyou, for you help
 
Try this,

strQuerySQL = "SELECT * FROM Table1 "
strQuerySQL = strQuerySQL & "WHERE (Table1.DRLID) = " & inVar & " "
strQuerySQL = strQuerySQL & "ORDER BY Table1.DRLID;"


There is a space on the end because I find that Key words operate better when they are surrounded by spaces. Thanks and Good Luck!

zemp
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top