We help IT Professionals succeed at work.
Get Started

Question about Ask Yes/No

Cyprexx IT
Cyprexx IT asked
on
344 Views
Last Modified: 2012-05-12
I'm creating a area where when a date is entered to a date field, it asks a question, what I need this to do, is when the user clicks yes it runs a different calculation and when no is answered it runs a different caluclation, how would this be done. I have this code here, that a user gave me..

Private Sub DayWorkComplete_BeforeUpdate(Cancel As Integer)

 If MsgBox("Is displayed date piror to current date?", 52, "Answer the question, bro") = vbYes Then
     ' Do yes
 Else
    ' Do No
 End If

End Sub




How would I make this work if the user click yes and wanted to run this code


Function GetNearestTuesday(dt As Date) As Date
    Dim intWeekDay As Integer
    Dim dtTemp As Date
    Select Case Weekday(dt)
        Case 3   ' Tuesday is day 3, so nearest Tuseday is the date passed to the function
            dtTemp = dt
        Case Is < 3  ' Date calculation for Sunday or Monday
            dtTemp = DateAdd("d", 3 - Weekday(dt), dt)
        Case Is > 3   ' Date calculation for other weekdays
            dtTemp = DateAdd("d", 10 - Weekday(dt), dt)
    End Select
   
    'If the calculated nearest tuesday is in the holiday table, add 7 days
    ' **** Note -- You need to adjust the following statement to use the correct table and field names ***
    If DCount("*", "tblHolidays", "Format([HolidayDate],'mm\/dd\/yyyy') = '" & Format(dtTemp, "mm\/dd\/yyyy") & "'") > 0 Then
       GetNearestTuesday = DateAdd("d", 7, dtTemp)
    Else  ' Otherwise simply return the calculated date
       GetNearestTuesday = dtTemp
    End If
   
End Function



Comment
Watch Question
CERTIFIED EXPERT
Top Expert 2016
Commented:
This problem has been solved!
Unlock 1 Answer and 6 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE