Yes no options in msgbox (1 Viewer)

anthonyphillips

Registered User.
Local time
Today, 20:30
Joined
Nov 7, 2007
Messages
50
Hi Guys

I am using Access 2007 (Works choice not mine) and I am trying to get a message box to pop up when a command button is pressed, simple enough but i want to have a yes no button on the box to either continue with form opening or to bounce back to the main form. I have written the vb code for the button but when i save it (without any compile errors or error messages) i get a dead button.

Can anybody help please.

Thanks

Anthony (Access Noob)
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 12:30
Joined
Aug 30, 2003
Messages
36,126
What is your code? Does other code run? If not, is the database in a trusted location or has code been enabled?
 

HiTechCoach

Well-known member
Local time
Today, 14:30
Joined
Mar 6, 2006
Messages
4,357
It would really help to see your VBA code.

You could try something like this at the beginning of the On Click event of a command button:

Code:
  If MsgBox("Do you want to do this now?", vbYesNo + vbCritical, "Confirm action ...") = vbNo Then
    Exit Sub
  
  End If
 

anthonyphillips

Registered User.
Local time
Today, 20:30
Joined
Nov 7, 2007
Messages
50
Here is the code

Exit Application Code
Private Sub Exit_Click()
On Error GoTo Err_Exit_Click


'Confirm close
If MsgBox("This will close Microsoft Access, Are you sure you want to quit?", vbYesNo + vbExclamation + vbDefaultButton2) = vbYes Then DoCmd.Quit

Exit_Exit_Click:
Exit Sub

Err_Exit_Click:
MsgBox Err.Description
Resume Exit_Exit_Click

End Sub

Thanks
Anthony
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 12:30
Joined
Aug 30, 2003
Messages
36,126
No problemo; hopefully that solved your problem?
 

anthonyphillips

Registered User.
Local time
Today, 20:30
Joined
Nov 7, 2007
Messages
50
Indeed thank you, another question for you that is defo beyond my access skills (i think lol) is there a way to password protect the tables so that everybody has to use the front end forms?

Plus is there then a way of having a button that will open the table after a password verification prompt?

thanks

Anthony
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 12:30
Joined
Aug 30, 2003
Messages
36,126
The most secure way would be Access Security, but that's actually not supported anymore if you have the db in accdb format. The first item under What's Gone in the same link goes over that topic, and I think some thoughts on how to secure the db are in the other links there.

Most of my users only have the runtime version of Access, and the ones that don't I force into that mode anyway, so I don't really worry about the users getting into the tables directly.
 

anthonyphillips

Registered User.
Local time
Today, 20:30
Joined
Nov 7, 2007
Messages
50
Ok a little bit more help and i'm done (i think) lol

Is there a way of coding the yes no box to display a msg when the no button is clicked rather than just returning to the menu ?

Thanks

Anthony
 

anthonyphillips

Registered User.
Local time
Today, 20:30
Joined
Nov 7, 2007
Messages
50
Update, this is the code for the yes button to opena new record .

Private Sub New_Record_Click()
On Error GoTo Err_Exit_Click

'Confirm close
If MsgBox("Has a ticket been raised for the incident you are logging?", vbYesNo + vbExclamation + vbDefaultButton2) = vbYes Then DoCmd.OpenForm "Report", acNormal

Exit_Exit_Click:
Exit Sub
Err_Exit_Click:
MsgBox Err.Description
Resume Exit_Exit_Click

End Sub

I now want a message on the no button if clicked.

Thanks

Anthony
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 12:30
Joined
Aug 30, 2003
Messages
36,126
Code:
If MsgBox("Has a ticket been raised for the incident you are logging?", vbYesNo + vbExclamation + vbDefaultButton2) = vbYes Then 
  DoCmd.OpenForm "Report", acNormal
Else
  MsgBox "Whatever"
End If
 

Users who are viewing this thread

Top Bottom