Results 1 to 2 of 2
  1. #1
    slaterino is offline Novice
    Windows XP Access 2003
    Join Date
    Apr 2009
    Posts
    25

    When creating a schedule in Visual Basic date changes between US and English format

    I have designed a way of creating a schedule using a Microsoft Access form and Visual Basic, which works exactly how I want, except for the fact that the date doesn't know which continent it's in. I know a lot of people have had problems with date, and I have looked at lots of solutions on forums, but none of these quite help with my problem.



    Essentially in my form you create a schedule, which can either be one date, or formed from multiple dates. When multiple dates are chosen you select a Start Date and End Date and then a selection of days (Mon, Tues, Wed) and weeks (All weeks, 1st week, 2nd week) where there will be scheduled dates. This works great except that for dates greater than the 12th day of the month it shows as US, while for the others it shows in English format, i.e.

    2nd March = 03/02/2011 (would display as US)
    20th March = 20/03/2011 (displayed in English format)

    My preference would be for the dates to all show in the English format, but wouldn't mind if I could get them all to display in the US format. The problem is that it's always a mix of both. Here's my VB coding for the dates. Is there anything I could add which would ensure that the format is correct. I've tried using the Format function but it's produced exactly the same results.

    Code:
    Private Sub cmdBuildSchedule_Click()
        Dim datThis As Date
        Dim strSQL As String
        Dim db As DAO.Database
        Dim intDOW As Integer 'day of week
        Dim intDIM As Integer 'Day in month
        If Me.grpRepeats = 2 Then
            If Not CheckDates() Then
                Exit Sub
            End If
        End If
        If Not CheckTimes() Then
            Exit Sub
        End If
        
        Set db = CurrentDb
        If Me.grpRepeats = 2 Then 'need to loop through dates
            For datThis = Format(Me.txtStartDate, "dd/mm/yyyy") To Format(Me.txtEndDate, "dd/mm/yyyy")
                intDIM = GetDIM(datThis)
                intDOW = Weekday(datThis)
                If Me("chkDay" & intDIM & intDOW) = True Or _
                        Me("chkDay0" & intDOW) = True Then
                    strSQL = "INSERT INTO tbl_temp_schedule_dates ( tscDate ) " & _
                        "Values(#" & _
                        datThis & ")"
                    db.Execute strSQL, dbFailOnError
                End If
            Next
         Else  'dates are there, just add the title, notes, times, location, Activity
            strSQL = "Update tbl_temp_schedule_dates Set "
                
            db.Execute strSQL, dbFailOnError
        End If
        Me.sfrm_temp_schedule_edit.Requery
        MsgBox "Temporary schedule built. " & _
            "You can now edit the schedule and " & _
            "append to the permanent schedule.", vbOKOnly + vbInformation, "Temp schedule complete"
    End Sub
    I've stripped out the mentions of the other fields as these didn't really need to be in there.

    Here's the function I use for when it's a multiple date activity:

    Code:
    Private Sub grpRepeats_AfterUpdate()
        Dim ctl As Control
        Dim intCounter As Integer
        Dim intWeek As Integer
        Dim intDay As Integer
        Me.txtEndDate.Visible = (Me.grpRepeats = 2)
        Me.txtStartDate.Visible = (Me.grpRepeats = 2)
        Me.sfrm_temp_schedule.Visible = (Me.grpRepeats = 1)
        For intWeek = 0 To 5
            For intDay = 1 To 7
                Set ctl = Me("chkDay" & intWeek & intDay)
                ctl.Visible = (Me.grpRepeats = 2)
                ctl.Value = 0
            Next
        Next
        Select Case Me.grpRepeats
            Case 2  'repeating
            Case 1
        End Select
    End Sub
    Sorry for such a long entry. Does anyone have any idea of how to cure this problem??

    Thanks for any help!
    Russ

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,917
    Does this link help: http://allenbrowne.com/ser-36.html

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Using Access Instead of Visual Basic
    By dinz in forum Programming
    Replies: 2
    Last Post: 12-19-2019, 10:33 AM
  2. Can't see visual basic code
    By Michele Keck in forum Forms
    Replies: 5
    Last Post: 09-29-2010, 11:31 AM
  3. Query in visual basic
    By Lucas83 in forum Programming
    Replies: 1
    Last Post: 06-10-2010, 11:00 AM
  4. Locking form with Visual Basic
    By rev_ollie in forum Forms
    Replies: 4
    Last Post: 04-29-2010, 07:27 AM
  5. Record Value in Visual Basic
    By chrismec in forum Programming
    Replies: 3
    Last Post: 12-09-2009, 04:14 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums