Advertisement

06.17.2008 at 07:48AM PDT, ID: 23491732
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

9.0

How to reformat a date so that a month such as January is stored in the format (MM) with a value of 01 ?

Asked by zimmer9 in Microsoft ADP, Access Forms, Access Coding/Macros

I am developing an Access 2003 application using Access as the front end and SQL Server as the back end database.

I have 2 text box input fields for the user to input into
1) a FROM DATE named txtDateFrom in the format MM/DD/YYYY.
2) a To DATE named txtDateTo in the format MM/DD/YYYY.

I use the following routines to validate the 2 dates entered by the user.
The problem is if the user inputs a FROM DATE = 1/1/2008 and a
                                                       TO DATE      = 06/1/2008.
The system thinks 1/1/2008 is > 06/1/2008 because the first date isn't saved with a month value of 01.
Do you know how I can save the format as a 2 position month field to avoid this problem ?
-----------------------------------------------
Private Sub txtDateFrom_AfterUpdate()
    Dim cn As ADODB.Recordset
    Dim str_sql1 As String
   
    Set cn = New ADODB.Recordset
       
    GetDateFrom = Me.txtDateFrom
     
    If IsDate(GetDateFrom) Then
        str_sql1 = "Update tblToFromDate Set FromDateVal = " & "'" & GetDateFrom & "'"
        DoCmd.RunSQL (str_sql1)
    End If

End Sub

Private Sub txtDateFrom_BeforeUpdate(Cancel As Integer)
    Dim strDateFrom
    If IsDate(Me.txtDateFrom) Then
       strDateFrom = CDate(Format(Me.txtDateFrom, "mm/dd/yyyy"))
    Else
       MsgBox "Please enter a valid date in the format mm/dd/yyyy", vbOKOnly, ""
       Cancel = True
    End If
End Sub

Private Sub txtDateTo_AfterUpdate()
    Dim cn As ADODB.Recordset
    Dim str_sql1 As String
           
    Set cn = New ADODB.Recordset
   
    GetDateTo = Me.txtDateTo
   
    If IsDate(GetDateTo) Then
        str_sql1 = "Update tblToFromDate Set ToDateVal = " & "'" & GetDateTo & "'"
        DoCmd.RunSQL (str_sql1)
    End If
 
End Sub

Private Sub txtDateTo_BeforeUpdate(Cancel As Integer)
    Dim strDateTo
    If IsDate(Me.txtDateTo) Then
       strDateTo = CDate(Format(Me.txtDateTo, "mm/dd/yyyy"))
    Else
       MsgBox "Please enter a valid date in the format mm/dd/yyyy", vbOKOnly, ""
       Cancel = True
    End If
End Sub

Private Function InspectDates() As Boolean
    Dim errString As String
    errString = ""

    If Not IsDate(Nz(Me.txtDateTo)) Then
        Me.txtDateTo.SetFocus
        errString = errString & "To run reports, enter valid Date To value" & vbCrLf
    End If
   
    If Not IsDate(Nz(Me.txtDateFrom)) Then
        Me.txtDateFrom.SetFocus
        errString = errString & "To run reports, enter valid Date From value" & vbCrLf
    End If
   
    If (Me.txtDateFrom > Me.txtDateTo) Then
        Me.txtDateFrom.SetFocus
        errString = errString & "To run reports, enter Date From <= Date To" & vbCrLf
    End If
   
    If errString <> "" Then
        InspectDates = False
        MsgBox errString, vbOKOnly, ""
    Else
        InspectDates = True
    End If
End Function


 
Start Free Trial
[+][-]06.17.2008 at 07:51AM PDT, ID: 21803636

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]06.17.2008 at 07:56AM PDT, ID: 21803695

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]06.17.2008 at 07:59AM PDT, ID: 21803732

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 30-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]06.17.2008 at 08:02AM PDT, ID: 21803782

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]06.17.2008 at 08:02AM PDT, ID: 21803785

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]06.17.2008 at 08:11AM PDT, ID: 21803908

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 30-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]06.17.2008 at 08:12AM PDT, ID: 21803914

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Microsoft ADP, Access Forms, Access Coding/Macros
Sign Up Now!
Solution Provided By: vadimrapp1
Participating Experts: 3
Solution Grade: A
 
 
 
Loading Advertisement...
20081112-EE-VQP-44 / EE_QW_2_20070628