Process Button

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

Guest

I have a process button that is very easy that is not working. I want to be
able to have the user push one button to run reports. In the report there is
a field called "ViolationNumber" that will drive what report should be
pulled. Each number from 1-10 reflects a certain style of report. But when
I use the code below all it does is pull up the first report
"ViolationNotice" for all the reports. What am I missing:

Private Sub CitationReports_Click()

Dim stDocNameViolationNotice As String
Dim stDocNameWRANotice As String
Dim stDocNamePenaltyNotice As String

stDocNameViolationNotice = "ViolationNotice"
stDocNameWRANotice = "WRANotice"
stDocNamePenaltyNotice = "PenaltyNotice"

If Number <= 1 Then
DoCmd.OpenReport stDocNameViolationNotice, acPreview
End If

If Number = 2 Then
DoCmd.OpenReport stDocNameWRANotice, acPreview
End If

If Number = 3 Then
DoCmd.OpenReport stDocNameWRANotice, acPreview
End If

If Number >= 4 Then
DoCmd.OpenReport stDocNamePenaltyNotice, acPreview
End If
End Sub
 
I can't tell from your description or your code what it is you are trying to
do.
You have 3 report names identified, but how does the 1 to 10 relate to them
as far as running additional reports?
 
"Number" isn't set anywhere so it will always be < 1 so the first report will
always run. Do you mean Me![Number]?

Regards
 
Kat

I suggest you replace your if statements with Case statements

Select case me!number

case 1
DoCmd.OpenReport stDocNameViolationNotice, acPreview

case 2, 3
DoCmd.OpenReport stDocNameWRANotice, acPreview

case 4
DoCmd.OpenReport stDocNamePenaltyNotice, acPreview

case else
msgbox("Invalid Selection")

End Select
 
Hi Again, The (3) reports are identified by a field called
"ViolationNumber". Each number represents a certian style of report. I am
trying to have the reports pulled only for a certain violations number:

1-ViolationNotice
2-3 WRANotice
4-PenaltyNotice
I tried to add a filter in the report but that is not working.
 
What do you mean Me![Number]?

I wrote that into the string and it did not work.

Gareth said:
"Number" isn't set anywhere so it will always be < 1 so the first report will
always run. Do you mean Me![Number]?

Regards

Kat said:
I have a process button that is very easy that is not working. I want to be
able to have the user push one button to run reports. In the report there is
a field called "ViolationNumber" that will drive what report should be
pulled. Each number from 1-10 reflects a certain style of report. But when
I use the code below all it does is pull up the first report
"ViolationNotice" for all the reports. What am I missing:

Private Sub CitationReports_Click()

Dim stDocNameViolationNotice As String
Dim stDocNameWRANotice As String
Dim stDocNamePenaltyNotice As String

stDocNameViolationNotice = "ViolationNotice"
stDocNameWRANotice = "WRANotice"
stDocNamePenaltyNotice = "PenaltyNotice"

If Number <= 1 Then
DoCmd.OpenReport stDocNameViolationNotice, acPreview
End If

If Number = 2 Then
DoCmd.OpenReport stDocNameWRANotice, acPreview
End If

If Number = 3 Then
DoCmd.OpenReport stDocNameWRANotice, acPreview
End If

If Number >= 4 Then
DoCmd.OpenReport stDocNamePenaltyNotice, acPreview
End If
End Sub
 
I have tried that also. What the main issues is it can not identify
"Number". I always thought you need to write in the string what field you
want and where you are pulling it from. In all the reports the field is
called "number" but it still can not locate it. Should I be using the term
in the Query "ViolationNumber" instead?
 

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


Back
Top