|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
I am trying to assing a value to a parameter defined in one of my queries in an Access Database. The ultimate purpose is to run a report named "Summary" that has this query as the source. The problem is that I've tried different ways to assing the parameters and they don't seem to be working. How would I go about making this code work?
CODE: Dim db As DAO.Database Set db = CurrentDb Dim parQ As QueryDef Set parQ = db.QueryDefs("Summary") Dim strGrp As String Select Case Selection.Value 'Form value entered Case 0 strGrp= "" Case 1 strGrp = "One" Case 2 strGrp = "Two" Case 3 strGrp= "Three" Case 4 strGrp = "Four" End Select parQ.Parameters("prmGrp") = strGrp parQ.Parameters("prmSel") = lstSelect.Value 'Assign value specified in Form DoCmd.OpenReport "Summary", acViewPreview 'This didn't work as it still prompted me to define the parameters. 'So I tried the following Code: Dim db As DAO.Database Set db = CurrentDb Dim parQ As QueryDef Set parQ = db.QueryDefs("Summary") Dim strGrp As String Dim rstQuery As Recordset Select Case Selection.Value 'Form value entered Case 0 strGrp= "" Case 1 strGrp = "One" Case 2 strGrp = "Two" Case 3 strGrp= "Three" Case 4 strGrp = "Four" End Select parQ.Parameters("prmGrp") = strGrp parQ.Parameters("prmSel") = lstSelect.Value Set rstQuery = parQ.OpenRecordset() DoCmd.OpenReport "Summary", acViewPreview 'This doesnt work either. I have to other parameters in the query, two dates read off directly as entered in the form, that are not explicitly defined as parameters. This code gives me an error that it expected more parameters. I assume it is the dates. But the dates do have values in the form that are apparently not being read. Any suggestions? All is appreciated. |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > Visual Basic Programming > Set Query Parameter for query that is report source |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|