We help IT Professionals succeed at work.

Ask Yes/no

Cyprexx IT
Cyprexx IT asked
on
I need to ask a yes/no when a date is entered in to a date field..

how would i accomplish this?
Comment
Watch Question

Database Architect / Application Developer
CERTIFIED EXPERT
Top Expert 2007
Commented:


Private Sub txtYourField_BeforeUpdate (Cancel As Integer)

 If MsgBox ("Do you want to enter this date?", 52,"The Question ...") = vbYes Then
     ' do yes
 Else
    ' Do No
 End If

End Sub

mx
CERTIFIED EXPERT
Most Valuable Expert 2012
Top Expert 2013
Commented:
Not 100% clear, but I think you want something like this in the BeforeUpdate event of your Date textbox:

Private Sub DateField_BeforeUpdate(cancel as Integer)
      if msgbox ("Did you really mean to enter this?", vbYesNo) = vbYes then
           ' do something
     else
         me.datefield.undo
         Cancel = true
    end if
end sub
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database Architect / Application Developer
CERTIFIED EXPERT
Top Expert 2007

Commented:
And you can use the Cancel argument if you like:



 If MsgBox ("Do you want to enter this date?", 52,"The Question ...") = vbYes Then
     ' do yes
 Else
    ' Do No
     Cancel = True ' cancel entering the date completely
 End If

End Sub

Explore More ContentExplore courses, solutions, and other research materials related to this topic.