commandbutton

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.
 
F

fredg

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.
 
G

Guest

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.
 

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

Similar Threads


Top