Need Button help!!

sbuckingham25

Registered User.
Local time
Today, 01:05
Joined
Jun 12, 2008
Messages
27
"I am trying to use a MsgBox when a button is clicked. The Warning comes up asking "Are you sure you want to Close this Job". If they click yes, then ckTMJobClosed check box is clicked (or 1), if they click no, then the check box is left uncheck (or 0). Once they select the form then closes.

I desperately need help with vb on this...I am just learning vb on basic. Thanks!"

I am also trying to create a button on my form once clicked to delete the record then exit the form. How can I do that?"

Thanks in advance!
 
If strContactEmail <> Me.lstComCtc.Column(6) Then 'Check emails match
iResponse = MsgBox("Selected site contact does not match the Primary contact. Continue sending?", vbYesNo, "Check contacts")
If iResponse <> vbYes Then Exit Sub
End If


Stick that on a button's click event.

Obv change to your variables etc
 
Is "strContactEmail" the name of the check box?
 
I just noticed that you said:

If they click yes, then ckTMJobClosed check box is clicked (or 1),
A checkbox in Access is either 0 (false) or -1 (true) not 1.
 
strContactEmail is a variable in my code that looks at the email address of a contact. If the person they try and send an email to doesn't have the same email then the warning pops up. If the user does not click Yes then it exits that routine. Otherwise, it sends the email.
 
Thanks, and oops you are right on the 0 and -1. Here is what I have:

Private Sub CkTMJob_Closed_Click()
If CkTMJob_Closed = -1 Then
iResponse = MsgBox("Are you sure you want to close this job?", 1 + vbQuestion, "Close Job")
If iResponse = vbYes Then Exit Sub
If iResponse = vbCancel Then CkTMJob_Closed = 0
End If
End Sub

The "iresponse" is not working. When I click on the ok or cancel button, it goes back to the form with the checkbox at -1
 
iResponse is another variable that stores the response on the messagebox.

Write "Dim iResponse as integer" underneath your sub name.

Have you put this on the button? I think you'll want to refer to the controls too - i.e. me.cktmjob etc
 
Code:
Private Sub CkTMJob_Closed_Click()
   iResponse = MsgBox("Are you sure you want to close this job?", [color=red]vbYesNo[/color] + vbQuestion, "Close Job")
[color=red]      If iResponse = vbYes Then 
         CkTMJob_Closed = True
      Else
         CkTMJob_Closed = False[/color]
      End If
End Sub
 
Perfect, thanks guys! Now, if iResponse is vbYes, I need it to close the form...suggestions?
 
Code:
Private Sub CkTMJob_Closed_Click()
   iResponse = MsgBox("Are you sure you want to close this job?", vbYesNo + vbQuestion, "Close Job")
      If iResponse = vbYes Then 
         CkTMJob_Closed = True
         [color=blue]DoCmd.Close acForm, Me.Name, acSaveNo[/color]
      Else
         CkTMJob_Closed = False
      End If
End Sub
 
Oh, and you don't need to change that line at all. It is generic but works for any form that it is on. Me.Name refers to the current form and you don't need to modify it.
 
Glad we could help. Good luck with the rest of your project. :)
 

Users who are viewing this thread

Back
Top Bottom