Yes or No Box

claddagh

Registered User.
Local time
Today, 19:48
Joined
Jun 15, 2005
Messages
63
Hi Guys.

I created a macro which I then converted to a module ( Not the best thing I know, but I have VERY little knowledge of VBA at the min )

Code:
Function mcr_archive_data()
On Error GoTo mcr_archive_data_Err

    DoCmd.SetWarnings False
    DoCmd.Hourglass True
    Beep
    MsgBox "You Are About To ARCHIVE Records From LIVE Customer Data ", vbCritical, "ARCHIVING DATA"
    DoCmd.OpenQuery "qry_archive_data", acViewNormal, acEdit
    Beep
    MsgBox "ARCHIVING DATA COMPLETE", vbInformation, "ARCHIVING DATA"


mcr_archive_data_Exit:
    Exit Function

mcr_archive_data_Err:
    MsgBox Error$
    Resume mcr_archive_data_Exit

End Function
This is the code it created.
How would I get it to give a yes or no prompt after this line
MsgBox "You Are About To ARCHIVE Records From LIVE Customer Data ",
That would enable the user to either continue, or cancel

Any help would be much appreciated
Thanks in advance

Max
 
Last edited by a moderator:
This is the proper way to do what you want.
Code:
Function mcr_archive_data()
On Error GoTo mcr_archive_data_Err

    Beep
    If MsgBox("Do you want to ARCHIVE Records From LIVE Customer Data?", vbQuestion + vbYesNo, "Archive Data") = vbYes Then
        DoCmd.Hourglass True
        DoCmd.SetWarnings False
        DoCmd.OpenQuery "qry_archive_data", acViewNormal, acEdit
        DoCmd.SetWarnings True
        DoCmd.Hourglass False
        Beep
        MsgBox "Archiving data completed.", vbInformation, "Archiving Data"
    Else 'user clicked No
        Beep
        MsgBox "Archiving Aborted", vbInformation
    End If
    
mcr_archive_data_Exit:
    DoCmd.SetWarnings True
    DoCmd.Hourglass False
    Exit Function

mcr_archive_data_Err:
    MsgBox Err.Number & " - " & Err.Description
    Resume mcr_archive_data_Exit

End Function
 
Last edited:
Works Great

ghudson,

Thank you very much for taking the time to look into and fix this for me.
The code You gave, worked just as you said.

This has fixed the problem I Was getting, and seems to be a little quicker too.


Thanks for you time & help.


Max
 

Users who are viewing this thread

Back
Top Bottom