Yes No Message Box

  • Thread starter Thread starter Gus
  • Start date Start date
G

Gus

Hello,

Thanks for your time.

The code below triggers a Yes No Response when users click on Yes the code
works, but when the click no, nothing happens. I am not sure why. Could
anyone please help out? Thanks. I want the user to go to a different fomr
when the click no (Agreement Search and Check Out).

Private Sub Form_Close()

Dim LResponse As Integer

LResponse = MsgBox("Do you wish to continue?", vbYesNo, "Continue")

If LResponse = vbYes Then
Docmd.OpenForm "New_Agreement_Number_Log_Form"
Else
Docmd.OpenForm "Agreement Search and Check Out"
End If
End Sub

Thanks.
 
Hi Gus,

You might try debugging and walking through your steps. Your code looks to
be fine except for the naming convention displayed here for your second form.
You might also change your variable to a type Integer rather than Long.
Won't really change the action, but will inprove on your overhead.

Best...
MPM
 
About the declaration... Sorry, saw that your variable name was LResponse.
Led me to believe it was declared as a Long...

About your form name for the second form... Displayed here you show the form
name as spaces. If you have named it as such, use underscores as you did on
the first name.

Again... Best
 
Hi MPM1100,

Thanks my code now works, but could I ask something else? When the Form Open
Agreement_Search_and_Check_Out Form is canceled or closed I get a Run-Time
error '2501' The OpenForm actions was canceled. How can I make this stop and
just no action after that?
The Debug option points to ---> Docmd.OpenForm
"Agreement_Search_and_Check_Out_Form"

Thanks.
 
It seems that I after doing some further testing I need to combine my
original code with this code.

Private Sub Form_Load()
Dim rst As DAO.Recordset
'Specifies to User if no record found then add
Set rst = Me.RecordsetClone
If rst.RecordCount = 0 Then
MsgBox "Agreement Not Found. Please make sure it was typed in Correctly. You
may need to add the Record?"
Docmd.Close
End If
End Sub

I need my form to go to the statement above and then ask whether the user
wants to add the new rocord, which is what my other code portion is
requesting. What is your suggestiong to combine? Thanks.
 
No Working so far...But working on it..

Private Sub Form_Load()
Dim rst As DAO.Recordset
'Specifies to User if no record found then add
Set rst = Me.RecordsetClone
If rst.RecordCount = 0 Then
Dim Response As Integer
Response = MsgBox("Agreement Not Found. Please make sure it was typed in
Correctly. You may need to add the Record. Do you want to Add?", vbYesNo,
Continue)
If Response = vbYes Then
DoCmnd.OpenForm "New_Agreement_Number_Log_Form"
Else
Docmd.OpenForm "Agreement_Search_and_Check_Out_Form"
Docmd.Close
End Sub
 
This is the current code there is an error message Run Time Error '424'
Object Required. It points to this line DoCmnd.OpenForm
"New_Agreement_Number_Log_Form".

Private Sub Form_Open(Cancel As Integer)
If Me.RecordsetClone.RecordCount = 0 Then
Cancel = True
If MsgBox("Agreement Not Found." & vbNewLine _
& "Please make sure it was typed in Correctly." & vbNewLine _
& "You may need to add the Record." & vbNewLine _
& "Do you want to Add?", vbYesNo, "Continue") = vbYes Then
DoCmnd.OpenForm "New_Agreement_Number_Log_Form"
Else
Docmd.OpenForm "Agreement_Search_and_Check_Out_Form"
End If
End If
End Sub

Thanks.
 
How does one go about replacing dll files and modules? do I need to download
the complete
windowsxp service pack 2? or can I replace items in question? Low virtual
memory? is that
a total neet to upgrade memory? I went in and increased the amount of my
virtual memory mb.
thanks!
 
Back
Top