R
RobVT
Using Access 2003.
I'm writing code for a couple message boxes that inform the user of the
number of query results before the query actually opens. If there are
no results, the user is asked to go back and revise their input on the
intro forms. If there is one, the message is singular, asking if
they'd like to proceed. And if there are more than one result, the
message is plural, asking if they'd like to proceed.
Here is a look at my code:
Private Sub cmdPCRRNext_Click()
Dim PCRRRes As String
Dim stDocName As String
Dim RRNoRes As String
Dim PCRR As Long
PCRR = DCount("*", "qryPCRoadRecon")
If PCRR = 0 Then
RRNoRes = MsgBox("There are no projects that match your criteria.
Please revise your project information or characteristics and try
again.", vbOKOnly, "Matching Error")
If RRNoRes = vbOK Then GoTo 10
ElseIf PCRR = 1 Then
PCRRRes = MsgBox("There is " & PCRR & " project that matches your
criteria. Would you like to continue?", vbYesNo, "Project
Characteristics Search Results")
If PCRRRes = vbYes Then
stDocName = "qryRoadReconRes"
DoCmd.OpenQuery stDocName, acNormal, acEdit
Else: GoTo 10
ElseIf PCRR > 1 Then
PCRRRes = MsgBox("There are " & PCRR & " projects that match your
criteria. Would you like to continue?", vbYesNo, "Project
Characteristics Search Results")
If PCRRRes = vbYes Then
stDocName = "qryRoadReconRes"
DoCmd.OpenQuery stDocName, acNormal, acEdit
Else: GoTo 10
10 End If
End Sub
For some reason, I keep getting an "Else without If" error when I try
to run the code (using a command button). I've been studying the code
and I can't figure out why it's doing that. I figured a fresh set of
eyes would help. Any suggestions?
Any help is much appreciated. Thanks and have a great day!
I'm writing code for a couple message boxes that inform the user of the
number of query results before the query actually opens. If there are
no results, the user is asked to go back and revise their input on the
intro forms. If there is one, the message is singular, asking if
they'd like to proceed. And if there are more than one result, the
message is plural, asking if they'd like to proceed.
Here is a look at my code:
Private Sub cmdPCRRNext_Click()
Dim PCRRRes As String
Dim stDocName As String
Dim RRNoRes As String
Dim PCRR As Long
PCRR = DCount("*", "qryPCRoadRecon")
If PCRR = 0 Then
RRNoRes = MsgBox("There are no projects that match your criteria.
Please revise your project information or characteristics and try
again.", vbOKOnly, "Matching Error")
If RRNoRes = vbOK Then GoTo 10
ElseIf PCRR = 1 Then
PCRRRes = MsgBox("There is " & PCRR & " project that matches your
criteria. Would you like to continue?", vbYesNo, "Project
Characteristics Search Results")
If PCRRRes = vbYes Then
stDocName = "qryRoadReconRes"
DoCmd.OpenQuery stDocName, acNormal, acEdit
Else: GoTo 10
ElseIf PCRR > 1 Then
PCRRRes = MsgBox("There are " & PCRR & " projects that match your
criteria. Would you like to continue?", vbYesNo, "Project
Characteristics Search Results")
If PCRRRes = vbYes Then
stDocName = "qryRoadReconRes"
DoCmd.OpenQuery stDocName, acNormal, acEdit
Else: GoTo 10
10 End If
End Sub
For some reason, I keep getting an "Else without If" error when I try
to run the code (using a command button). I've been studying the code
and I can't figure out why it's doing that. I figured a fresh set of
eyes would help. Any suggestions?
Any help is much appreciated. Thanks and have a great day!