Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I'm trying to populate a recordset using a query in Excel VB code as below :-
Dim db As Database Dim rs1 As Recordset Dim SQLstr As String Dim OrigCP As Variant OrigCP = "AB123" db = "c:\my.mdb" SQLstr = "SELECT History.Field2, History.OrigCP FROM History WHERE History.OrigCP=" & OrigCP Set rs1 = db.OpenRecordset(SQLstr) I get an error 3061 (Too few Parameters - Expected 1). Any ideas? - I've done this lots directly in Access VB OK. Thanks. |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Andy,
Try SQLstr = "SELECT History.Field2, History.OrigCP FROM History WHERE " & _ History.OrigCP = "'" & OrigCP & "'" -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com "Andy" wrote in message ... I'm trying to populate a recordset using a query in Excel VB code as below :- Dim db As Database Dim rs1 As Recordset Dim SQLstr As String Dim OrigCP As Variant OrigCP = "AB123" db = "c:\my.mdb" SQLstr = "SELECT History.Field2, History.OrigCP FROM History WHERE History.OrigCP=" & OrigCP Set rs1 = db.OpenRecordset(SQLstr) I get an error 3061 (Too few Parameters - Expected 1). Any ideas? - I've done this lots directly in Access VB OK. Thanks. |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Great - thanks - worked OK.
"Andy" wrote: I'm trying to populate a recordset using a query in Excel VB code as below :- Dim db As Database Dim rs1 As Recordset Dim SQLstr As String Dim OrigCP As Variant OrigCP = "AB123" db = "c:\my.mdb" SQLstr = "SELECT History.Field2, History.OrigCP FROM History WHERE History.OrigCP=" & OrigCP Set rs1 = db.OpenRecordset(SQLstr) I get an error 3061 (Too few Parameters - Expected 1). Any ideas? - I've done this lots directly in Access VB OK. Thanks. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
adodb.recordset with excel | Excel Programming | |||
Type recordset/recordset? | Excel Programming | |||
Recordset in Excel | Excel Programming | |||
Display a Recordset in Excel | Excel Programming | |||
Recordset Opening Excel File | Excel Programming |