Opening a recordset off a parameterized query

coline

New Member
Joined
Apr 18, 2003
Messages
37
Hi, I've been following instructions on this topic from "MS Access 2000 Power Programming: the authoritative solution" p. 162", but I can't get the #$%& code to work when the parameter is text as opposed to numeric. My code is below, and your comments are appreciated!!

Dim appExcel As New Excel.Application
Dim wkbExcel As Excel.Workbook
Dim wkshtExcel As Excel.Worksheet
Dim rngExcel As Excel.Range
Dim rs As New ADODB.Recordset
Dim catCurr As New ADOX.Catalog
Dim cmdcurr As New ADODB.Command

'The code below comes out of "MS Access 2000 Power Programming: the authoritative solution" p. 162 - how to open up a recordset off a parameterized query.

catCurr.ActiveConnection = CurrentProject.Connection

Set cmdcurr = catCurr.Procedures("REVIEW ARQni Personnel SW allocations").Command

'The code below that defines the parameter does not work in the current form, although I've gotten it to work to run it off a numeric field. The example in the book uses a date. Ideally, I would like to define the parameter by linking it to data entered in a form (e.g. forms![form name]![control name]. The parameter [enter unqid] is defined in the query criteria.

cmdcurr.Parameters("[Enter UNQID]") = "5L07"

rs.Open cmdcurr, , adOpenKeyset, adLockReadOnly, adCmdStoredProc
 

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
I think that you may need to wrap quotes in it.
cmdcurr.Parameters("[Enter UNQID]") = "'5L07'"

(Note the extra ' added)

HTH

Peter
 
Upvote 0

Forum statistics

Threads
1,221,567
Messages
6,160,540
Members
451,655
Latest member
rugubara

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top