message box issues

S

starkbergs

I am working on a form "A" and i have created a Message box that has
'yes' and 'No' options.

if i click on the yes button then it should open up a new form "B"
for me,But if i click on the No option then it should let me stay in
the same form that i have been working previsiouly.

I have this code here.Can anyone help me as to what i am missing here.

Private Sub Form_Open(Cancel As Integer)
If IsNull(CompanyID) Or IsNull(InspectorID) Then
MsgBox "", vbYesNo + vbCritical + vbDefaultButton2
If Response = vbYes Then
DoCmd.OpenForm "", , , , acFormAdd
Else
If Response = vbNo then
Exit Sub
End if
 
D

David Sisson

This is a Word group, but the command in Access seems to be the same.

Try,

Private Sub Form_Open(Cancel As Integer)
If IsNull(CompanyID) Or IsNull(InspectorID) Then
Response = InputBox("", vbYesNo + vbCritical + vbDefaultButton2)
If Response = vbYes Then
DoCmd.OpenForm "", , , , acFormAdd 'I'm not sure about this.
Else
If Response = vbNo Then
Exit Sub
End If
 
S

starkbergs

This is a Word group, but the command in Access seems to be the same.

Try,

Private Sub Form_Open(Cancel As Integer)
If IsNull(CompanyID) Or IsNull(InspectorID) Then
    Response = InputBox("", vbYesNo + vbCritical + vbDefaultButton2)
    If Response = vbYes Then
    DoCmd.OpenForm "", , , , acFormAdd 'I'm not sure about this.
Else
    If Response = vbNo Then
    Exit Sub
End If

Thank you so much.
 

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

Top