commandbutton

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have the following vb code for a form command button that i wish to open a
report with. The report is fed by a StoredProcedure that asks for the
parameter ScheduleDetailsID, why cant i get the button to pass this
parameter.

Private Sub Print_Roster_Click()

Dim stDocName As String

stDocName = "CourseRoster"
stLinkCriteria = "[ScheduleDetailsID]=" & Me![ScheduleDetailsID]
DoCmd.OpenReport stDocName, acPreview, stLinkCriteria

I've asked this in the past and was directed to look for InputParameter
threads, havent found anything I understand - new to ADP. Thank you for your
help.
 
I have the following vb code for a form command button that i wish to open a
report with. The report is fed by a StoredProcedure that asks for the
parameter ScheduleDetailsID, why cant i get the button to pass this
parameter.

Private Sub Print_Roster_Click()

Dim stDocName As String

stDocName = "CourseRoster"
stLinkCriteria = "[ScheduleDetailsID]=" & Me![ScheduleDetailsID]
DoCmd.OpenReport stDocName, acPreview, stLinkCriteria

I've asked this in the past and was directed to look for InputParameter
threads, havent found anything I understand - new to ADP. Thank you for your
help.

You seem to be missing a comma.
You placed the Where clause argument in the Filter argument position.

DoCmd.OpenReport stDocName, acPreview, , stLinkCriteria

You're Where clause assumes the [ScheduledDetailsID] field is a Number
datatype. Also, you're use of the Me! keyword will only work if the
code is on the same form as the [ScheduleDetailsID] control, not on a
different form nor in a Module.
 
Thanks code slip but the form command button's click procedure needs to pass
ScheduleDetailsID to the reports SP. Still not workin. Before the report runs
it asks for ScheduleDetailsID each time.

fredg said:
I have the following vb code for a form command button that i wish to open a
report with. The report is fed by a StoredProcedure that asks for the
parameter ScheduleDetailsID, why cant i get the button to pass this
parameter.

Private Sub Print_Roster_Click()

Dim stDocName As String

stDocName = "CourseRoster"
stLinkCriteria = "[ScheduleDetailsID]=" & Me![ScheduleDetailsID]
DoCmd.OpenReport stDocName, acPreview, stLinkCriteria

I've asked this in the past and was directed to look for InputParameter
threads, havent found anything I understand - new to ADP. Thank you for your
help.

You seem to be missing a comma.
You placed the Where clause argument in the Filter argument position.

DoCmd.OpenReport stDocName, acPreview, , stLinkCriteria

You're Where clause assumes the [ScheduledDetailsID] field is a Number
datatype. Also, you're use of the Me! keyword will only work if the
code is on the same form as the [ScheduleDetailsID] control, not on a
different form nor in a Module.
 
Back
Top