BadKitty
Registered User.
- Local time
- Today, 02:04
- Joined
- Jul 7, 2005
- Messages
- 55
i know this is really simple, but i can't for the life of me remember how to do it!
so here's the sitch...
i've created a database for city permits to be issued. there are 4 types of permits (hydrant, meter, sewer, tap). in one of my forms, i have the user enter the type of permit (h, m, s, or t) and have the permit number set to autonumber. i created a query that concatenates the letter entered w/the autonumber assigned (ie - h12) and used that field (PermitNo) on another form which is to enter payment information. on this form i also have a button to print the current permit (open report). thing is, i have four seperate reports, each designed to look like whichever permit it is. i'd like to add the select case statement or an if else statement to the open report command so that if the current permit is h12 it will open the hydrant permit report. the code is pasted below. what else needs to be inside the quotes to accomplish this? also, please let me know if my syntax is correct.
right now i have the cmd button set to preview...
Private Sub cmdPreviewPermit_Click()
On Error GoTo Err_cmdPreviewPermit_Click
Dim permitNo As String
If permitNo = "h" Then
DoCmd.OpenReport "rptHydrant", acPreview
ElseIf permitNo = "m" Then
DoCmd.OpenReport "rptMeter", acPreview
ElseIf permitNo = "s" Then
DoCmd.OpenReport "rptSewer", acPreiview
ElseIf permitNo = "t" Then
DoCmd.OpenReport "rptTap", acPreview
End If
Exit_cmdPreviewPermit_Click:
Exit Sub
Err_cmdPreviewPermit_Click:
MsgBox Err.Description
Resume Exit_cmdPreviewPermit_Click
End Sub
thanx in advance!

so here's the sitch...
i've created a database for city permits to be issued. there are 4 types of permits (hydrant, meter, sewer, tap). in one of my forms, i have the user enter the type of permit (h, m, s, or t) and have the permit number set to autonumber. i created a query that concatenates the letter entered w/the autonumber assigned (ie - h12) and used that field (PermitNo) on another form which is to enter payment information. on this form i also have a button to print the current permit (open report). thing is, i have four seperate reports, each designed to look like whichever permit it is. i'd like to add the select case statement or an if else statement to the open report command so that if the current permit is h12 it will open the hydrant permit report. the code is pasted below. what else needs to be inside the quotes to accomplish this? also, please let me know if my syntax is correct.

Private Sub cmdPreviewPermit_Click()
On Error GoTo Err_cmdPreviewPermit_Click
Dim permitNo As String
If permitNo = "h" Then
DoCmd.OpenReport "rptHydrant", acPreview
ElseIf permitNo = "m" Then
DoCmd.OpenReport "rptMeter", acPreview
ElseIf permitNo = "s" Then
DoCmd.OpenReport "rptSewer", acPreiview
ElseIf permitNo = "t" Then
DoCmd.OpenReport "rptTap", acPreview
End If
Exit_cmdPreviewPermit_Click:
Exit Sub
Err_cmdPreviewPermit_Click:
MsgBox Err.Description
Resume Exit_cmdPreviewPermit_Click
End Sub
thanx in advance!
