Results 1 to 7 of 7

Thread: Date mismatch

  1. #1
    Join Date
    Nov 2009
    Posts
    49

    Unanswered: Date mismatch

    Hi guys,

    I am using Access 2007

    This error keeps blowing my brain because I can't see a reason for it! I have the following coding:

    Dim strweekday as string

    strweekday = "'" & WeekdayName(Weekday(Dateof.Value) - 1) & "'"

    Where Dateof.value is a date in a txtbox; the dates use the Date Picker function so whatever is inputed is always a date.

    And I get a mismatch error!

    I have even split it up into separate functions:


    Dim strweek as integer
    Dim strweekday as string

    strweek = Weekday(Dateof.Value)
    strweekday = "'" & (WeekdayName(strweek - 1)) & "'"

    Get the same error and narrowed it down to Weekday() function. I am not sure what I am doing wrong especially as I have used this coding elsewhere in the database and it has worked perfectly well.

    I have also changed strweek to be a variant, long, string and date data types and they all come up with the error. Also changed Dateof.value to its full address. Nothing.

    Also made sure that the format of the Dateof textbox is in General Date format.

    Thanks for any help that you are able to give

    Phil
    Last edited by pb190; 01-14-10 at 07:45.

  2. #2
    Join Date
    Mar 2007
    Posts
    277
    Time to import everything into a new db and see if you still have the same issue.
    BTAB Development - How to import everything into a new mdb file
    RuralGuy (RG for short) aka Allan Bunch MS Access MVP - acXP, ac07, ac10 - WinXP Pro, Win7 Pro
    Please reply to this forum so all may learn.

  3. #3
    Join Date
    Nov 2009
    Posts
    49
    Hmm. tried importing same problem.

    I even tried replacing weekday() contents to a specific date and it won't work :s

    This example is copied off the internet and comes up with the same error:

    Dim LWeekday As Integer

    LWeekday = Weekday(#12/03/2001#, vbSunday)

    Still a mismatch.

    But when i just put this example into a totally blank new form within my original database this works perfectly fine :s

    So i created a new textbox on the form and put in:

    Private Sub Text0_Click()
    Dim LWeekday As Integer

    LWeekday = Weekday(#12/3/2001#, vbSunday)
    Text0.Value = LWeekday
    End Sub

    And stills does mismatch, so maybe it is a form/detail property?
    Last edited by pb190; 01-14-10 at 10:32. Reason: Update

  4. #4
    Join Date
    Mar 2007
    Posts
    277
    Any chance you have come up with a mysterious bogus MISSING reference?
    RuralGuy (RG for short) aka Allan Bunch MS Access MVP - acXP, ac07, ac10 - WinXP Pro, Win7 Pro
    Please reply to this forum so all may learn.

  5. #5
    Join Date
    Nov 2009
    Posts
    49
    Hi,

    I am not sure, how do you check?

    Would a missing reference only affect a single form? I would have thought a reference would affect the whole database.

    Thanks
    Phil

  6. #6
    Join Date
    Mar 2007
    Posts
    277
    RuralGuy (RG for short) aka Allan Bunch MS Access MVP - acXP, ac07, ac10 - WinXP Pro, Win7 Pro
    Please reply to this forum so all may learn.

  7. #7
    Join Date
    Nov 2009
    Posts
    49
    Ah it was so annoying nothing changed, so had to do it the old fashioned way...

    Find the number of weeks...
    yh tiresome but it works, won't have to look at it again... hopefully

    But thanks for your help.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •