If Statement Not Working

D

DS

I have this If statement with 3 different conditions, but it doesn't
seem to be working. Is the Syntax wrong?

Private Sub Command27_Click()
On Error GoTo Err_Command27_Click

If Forms!Sales!Guests = Forms!Sales.SalesDetails!Text58 Then
DoCmd.Close
Else
If Forms!Sales!Guests > Forms!Sales.SalesDetails!Text58 Then
DoCmd.OpenForm "NotEnuf"
If Forms!Sales!Guests < Forms!Sales.SalesDetails!Text58 Then
DoCmd.OpenForm "TooMany"
Exit_Command27_Click:
Exit Sub
Err_Command27_Click:
MsgBox Err.Description
Resume Exit_Command27_Click
End If
End If
End If
End Sub

Thanks
DS
 
R

Reg

DS,

Your procedure needs to look like this:

Private Sub Command27_Click()
On Error GoTo Err_Command27_Click

If Forms!Sales!Guests = Forms!Sales.SalesDetails!Text58 Then
DoCmd.Close
ElseIf Forms!Sales!Guests > Forms!Sales.SalesDetails!Text58 Then
DoCmd.OpenForm "NotEnuf"
ElseIf Forms!Sales!Guests < Forms!Sales.SalesDetails!Text58 Then
DoCmd.OpenForm "TooMany"
End If

Exit_Command27_Click:
Exit Sub
Err_Command27_Click:
MsgBox Err.Description
Resume Exit_Command27_Click

End Sub


Reg
 
D

DS

Reg said:
DS,

Your procedure needs to look like this:

Private Sub Command27_Click()
On Error GoTo Err_Command27_Click

If Forms!Sales!Guests = Forms!Sales.SalesDetails!Text58 Then
DoCmd.Close
ElseIf Forms!Sales!Guests > Forms!Sales.SalesDetails!Text58 Then
DoCmd.OpenForm "NotEnuf"
ElseIf Forms!Sales!Guests < Forms!Sales.SalesDetails!Text58 Then
DoCmd.OpenForm "TooMany"
End If

Exit_Command27_Click:
Exit Sub
Err_Command27_Click:
MsgBox Err.Description
Resume Exit_Command27_Click

End Sub


Reg
Your're Good. That worked Great!!!
Thank You. You saved me from another painful afternoon!
DS
 

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