if statement

T

Taher

Hi there

I have a procedure below which is being triggered when
user hits the command button. It is as below
Private Sub Command149_Click()
On Error GoTo Err_Command149_Click

Dim msg, style, Mycheck, checkcriteria, response,
Mystring, style1
msg = "Did you Approve scorecard!"
style = vbYesNo + vbExclamation

Msg1 = " Did you enter Approvers name!"
Msg2 = "Please enter Approvers name!"
style1 = vbExclamation

style = vbYesNo + vbExclamation




Mycheck = IsNull(checkcriteria)
If Mycheck = False Then
response = MsgBox(msg, style, Title)
End If
If response = vbNo Then
DoCmd.Close
End If

If response = vbYes Then
MsgBox Msg1, style
End If

If response = vbYes Then
DoCmd.Close
End If

'End If

' If response = vbNo Then
' MsgBox Msg2, style1
'GoTo Exit_Command149_Click
'End If
' End If
Exit_Command149_Click:
Exit Sub

Err_Command149_Click:
MsgBox Err.Description
Resume Exit_Command149_Click

End Sub

It works like this

1.when user hits the command button the first screen pops
up, if user hits not it closes
2. if users chooses yes hten another screen pops and ask
yes or no to user
3. if user chooses yes it closes
4. if user chooses no then also it closes. here is the
problem, i dont want it to be closed i want another screen
to pop up, but i am for some reason not able to do that.

I would appreciate if someone could help me with this code.

Thank you.
 
D

Douglas J. Steele

You're not trapping the response to the second message box.

Where you have

If response = vbYes Then
MsgBox Msg1, style
End If

you need

If response = vbYes Then
response = MsgBox (Msg1, style)
End If

just like you had the first time.

Since you're not capturing the response to the second message box, it's
still using the Yes from the first message box.
 

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