Passing parameter problem

G

Guest

Why do I still get prompted for parameter input when this code is supposed to be passing the values to the underlying query, qryRptWorkshop? Note, frmReportSelector!txtYear contains a textbox for the year (txtYear) and option group for the month (fraMo).

Private Sub Report_Open(Cancel As Integer
Dim db As Database, p1 As Parameter, p2 As Paramete
Dim Xx As Integer, str As String, rpt As Repor
Dim mm As Integer, rsnam As Strin
Dim rs As Recordse
Dim qy As QueryDe
mm = Forms!frmReportSelector!fraMo.Valu
Xx = Forms!frmReportSelector!fraMo.Valu

Select Case X
Case 28, 2
If Forms!frmReportSelector!txtYear = "2004" The
Xx = 2
Els
Xx = 2
End I
Case 1, 4, 6, 9, 1
Xx = 3
Case 3, 5, 7, 8, 10, 1
Xx = 3
End Selec

Set db = CurrentDb(
Set qy = db.QueryDefs!qryRptWorksho
Set p1 = qy.Parameters!pStar
Set p2 = qy.Parameters!pEn
p1.Value = CDate(Format(mm & "/1/" & CLng(Forms!frmReportSelector!txtYear), "short date")
p2.Value = CDate(Format(mm & "/" & Xx & "/" & CLng(Forms!frmReportSelector!txtYear), "short date")

Set rs = qy.OpenRecordse
rs.Requer
rsnam = rs.Nam
Me.RecordSource = rsna

End Su
 
K

Kevin Sprinkel

I suspect that either the parameter is defined in the
query or that the query does not contain the field.
-----Original Message-----
Why do I still get prompted for parameter input when this
code is supposed to be passing the values to the
underlying query, qryRptWorkshop? Note,
frmReportSelector!txtYear contains a textbox for the year
(txtYear) and option group for the month (fraMo).
Private Sub Report_Open(Cancel As Integer)
Dim db As Database, p1 As Parameter, p2 As Parameter
Dim Xx As Integer, str As String, rpt As Report
Dim mm As Integer, rsnam As String
Dim rs As Recordset
Dim qy As QueryDef
mm = Forms!frmReportSelector!fraMo.Value
Xx = Forms!frmReportSelector!fraMo.Value

Select Case Xx
Case 28, 29
If Forms!frmReportSelector!txtYear = "2004" Then
Xx = 29
Else
Xx = 28
End If
Case 1, 4, 6, 9, 11
Xx = 30
Case 3, 5, 7, 8, 10, 12
Xx = 31
End Select

Set db = CurrentDb()
Set qy = db.QueryDefs!qryRptWorkshop
Set p1 = qy.Parameters!pStart
Set p2 = qy.Parameters!pEnd
p1.Value = CDate(Format(mm & "/1/" & CLng(Forms!
frmReportSelector!txtYear), "short date"))
p2.Value = CDate(Format(mm & "/" & Xx & "/" & CLng(Forms!
frmReportSelector!txtYear), "short date"))
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top