Option Group and Combo Box

S

ScubaDee

Can someone help me out here?? I have a combo box with a list of departments
on it...and I have an option group listing the different reports. I want the
user to pick a department and then a report and have it open for that
specific department.

The code works but it pops up the "enter the parameter value" dialogue and I
have to re-type the department...both strange and tedious to the user. Here
is my code

Dim reportname

If Me!Action = 1 Then reportname = "Rpt_PaperworkIncomplete"
If Me!Action = 2 Then reportname = "Rpt_TBD"
If Me!Action = 3 Then reportname = "Rpt_TBD"
If Me!Action = 4 Then reportname = "Rpt_TBD"
If Me!Action = 5 Then reportname = "Rpt_TBD"

Dim stLinkCriteria As String
stLinkCriteria = "[Position]=" & "" & Me![lkp] & ""

DoCmd.OpenReport reportname, acViewPreview, , stLinkCriteria


PLEASE HELP :)
 
J

John W. Vinson

Can someone help me out here?? I have a combo box with a list of departments
on it...and I have an option group listing the different reports. I want the
user to pick a department and then a report and have it open for that
specific department.

The code works but it pops up the "enter the parameter value" dialogue and I
have to re-type the department...both strange and tedious to the user. Here
is my code

Dim reportname

If Me!Action = 1 Then reportname = "Rpt_PaperworkIncomplete"
If Me!Action = 2 Then reportname = "Rpt_TBD"
If Me!Action = 3 Then reportname = "Rpt_TBD"
If Me!Action = 4 Then reportname = "Rpt_TBD"
If Me!Action = 5 Then reportname = "Rpt_TBD"

Dim stLinkCriteria As String
stLinkCriteria = "[Position]=" & "" & Me![lkp] & ""

DoCmd.OpenReport reportname, acViewPreview, , stLinkCriteria


PLEASE HELP :)

Well... since none of us can see your tables, or the report, or its criteria,
it's a bit hard to be precise; nor do you indicate where on the form the
Department might be found.

My crystal ball may be a bit hazy, but I'd suggest changing your code to:

Dim reportname As String
Dim stLinkCriteria As String
Select Case Me!Action
Case 1
reportname = "Rpt_PaperworkIncomplete"
Case Else
reportname = "Rpt_TBD"
End Select
stLinkCriteria = "[Position] = '" & Me![lkp] & _
"' AND Dept = '" & Me!Dept & "'"
DoCmd.OpenReport reportname, acViewPreview, , stLinkCriteria
 
J

Jeff Boyce

I don't see in your code where you set the value of "reportname"...

Regards

Jeff Boyce
Microsoft Access MVP

--
Disclaimer: This author may have received products and services mentioned
in this post. Mention and/or description of a product or service herein
does not constitute endorsement thereof.

Any code or pseudocode included in this post is offered "as is", with no
guarantee as to suitability.

You can thank the FTC of the USA for making this disclaimer
possible/necessary.
 

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