Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

msg box

Status
Not open for further replies.
Dec 5, 2005
40
0
0
US
I want to prompt the user to make sure that they want to add a record.

There is one exception... if the client is equal to clientid = 100, otherwise prompt



text in the box "Are you sure you want to add the record?"

Yes, then add
No, then cancel
 
Here's an example of the yes/no message box:

Code:
Dim msg As String, button As Variant, title As String, response As Variant
msg = "Vehicle is Shopped - Do you want to dispatch anyway?"
button = vbYesNo + vbDefaultButton2
title = "Vehicle Shopped!"

response = MsgBox(msg, button, title)
If response = vbYes Then
  'what to do if yes
Else
  'what to do if not
End If

Paul
MS Access MVP 2007/2008
 
Something like...
Code:
If ClientID <> 100 Then
   If Msgbox("Are you sure you want to add the record?",vbYesNo+vbQuestion,"Verify Add Record") = vbYes Then
      [i]Add record code here[/i]
   Else
      [i]Cancel code here[/i]
   End If
End If

Randy
 
Randy... can you look at this...

If CLID <> 8 Then
If MsgBox("If the last record is less than 6 months old you must apply units shown to that 'contact path', otherwise, add the units shown to a new 'contact path', see Property Manager for details.", vbYesNo + vbQuestion, "Business Rule Violation") = vbYes Then
DateEntered = Now()
Login = CurrentUser
CLID = [Forms]![trf_Menu_Agent]![allCLID]
Else
selDateShown.SetFocus
End If
End If

On the 'else' I want to cancel adding the record. I thought setting the focus would work... but it doesn't ... Thanks so much for your help so far.
 
Actually...

if the clid = 8 then set the values,

if the clid <> 8 then give the yes no msgbox and set the values for the 'yes'... but on the 'no' do nothing

Thanks

Private Sub Form_BeforeInsert(Cancel As Integer)
If CLID <> 8 Then
DateEntered = Now()
Login = CurrentUser
CLID = [Forms]![trf_Menu_Agent]![allCLID]


If MsgBox("Click Yes, verifying that the additional contact path is 6 months later than the previous. Otherwise, No. See your property manager for details.", vbYesNo + vbQuestion, "Business Rule Violation") = vbYes Then
DateEntered = Now()
Login = CurrentUser
CLID = [Forms]![trf_Menu_Agent]![allCLID]
Else
"Dont Do Anything"
End If
End If


End Sub
 
Replace this:
"Dont Do Anything"
with this:
Cancel = True

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top