Results 1 to 5 of 5
  1. #1
    Helen's Avatar
    Helen is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jan 2009
    Location
    The Hill, Australia
    Posts
    28

    SOLVED Same code, different form, one good, other type mismatch

    SOLVED.
    Here's the code, really simple!

    Dim DDay as integer
    Dim Default as Date

    Default = CDate(Int(Now()))
    DDay = Day(Default) - debugger highlights this line

    part 1
    I copied the code behind a command button in one form that was working perfectly. Pasted it for another command button and I get Error 13 type mismatch!!! The original still works fine.
    Both are forms. The one that works fine is just a simple form. The one that gives the type mismatch has 2 subforms on it. Neither DDay, nor Default are fields in the forms, just used within the coding.

    Am I being really stupid somehow?

    ETA - YUP, STUPID!!! Had a field called 'DAY' in the second form. I've been using this file for over a year, and been getting rid of macros and inserting VB in their place.
    It was a BIG job to locate ALL the references to that 'Day' throughout queries, tables etc, and change them all to DayNum, but it's done now.

    later that day.........
    Thought that'd be it, but NOOOOOO

    Part 2


    Now, instead of an error saying 'type mismatch', the debugger says that it can't find the field referred to in the expression!

    after more searching the net.............

    Part 3

    Solved!
    First, in case 'Default' was a reserved word, changed it to Defolt.
    Didn't solve the problem.
    Shoving "VBA." in front of the Day function, i.e. DDay = VBA.Day(Defolt) solve the problem.

    Thanks for being here anyway.
    Last edited by Helen; 05-18-2009 at 01:46 AM.

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 10 Access 2013 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922

  3. #3
    Helen's Avatar
    Helen is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jan 2009
    Location
    The Hill, Australia
    Posts
    28
    Thankyou!! An invaluable resource, especially for a relative newbie to VB programming!!

  4. #4
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 10 Access 2013 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Quote Originally Posted by Helen View Post
    Thankyou!! An invaluable resource, especially for a relative newbie to VB programming!!
    Agreed. There is a ton of good stuff on Allen's site.

  5. #5
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 10 Access 2013 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    BTW, the fact that VBA.Day() works should tell you that you have another Day function defined somewhere. If not then there is some corruption and you should try a /decompile.

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

Similar Threads

  1. aSTR = Dir("C:\*.*") >> "Type Mismatch"
    By JGrant in forum Programming
    Replies: 1
    Last Post: 03-28-2009, 05:17 AM
  2. Replies: 2
    Last Post: 03-23-2009, 05:39 AM
  3. SQL - Read any good books lately?
    By metaDM in forum Queries
    Replies: 2
    Last Post: 03-05-2009, 12:46 PM
  4. "Type Mismatch" Error
    By elmousa68 in forum Access
    Replies: 2
    Last Post: 12-05-2006, 08:28 AM
  5. Creating a *Good* Custom Message Box
    By Jerimiah33 in forum Forms
    Replies: 1
    Last Post: 11-09-2005, 04:47 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