Results 1 to 7 of 7
  1. #1
    jonesy29847 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Mar 2010
    Location
    Detroit area
    Posts
    43

    DCount type mismatch

    I am receiving a Datatype mismatch error when the following espression is used. TaskDate is formatted as a Short Date.



    Code:
    Iter = DCount("[TaskDate]", "Job Number and Date Range")

  2. #2
    ajetrumpet is offline VIP
    Windows Vista Access 2007
    Join Date
    Mar 2010
    Location
    N/A
    Posts
    2,694
    in vba?

    first, take the braces off. second, if ITER is not a long or integer, that's probably the issue.

  3. #3
    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,922
    Adam,
    I see no braces used by the OP. {} All I see are brachets. [] which should work except they were not used in the 2nd argument which would be necessary with embedded spaces in a name. Lastly, if in fact the [TaskDate] is truly a dateTime field then ITER should be one as well. Sorry for jumping in here.

  4. #4
    ajetrumpet is offline VIP
    Windows Vista Access 2007
    Join Date
    Mar 2010
    Location
    N/A
    Posts
    2,694
    Quote Originally Posted by RuralGuy View Post
    Adam,
    I see no braces used by the OP. {} All I see are brachets. [] which should work except they were not used in the 2nd argument which would be necessary with embedded spaces in a name. Lastly, if in fact the [TaskDate] is truly a dateTime field then ITER should be one as well. Sorry for jumping in here.
    Well, then I guess I need to brush up on my enclosure characters! Sorry about that...YES, drop the brackets, NOT braces. IMO, it's a good practice. If I remember, domain aggregates in VBA though, in the field argument section, worth with AND without them, so that part of my post is really irrelevant.

    Quote Originally Posted by RuralGuy View Post
    Lastly, if in fact the [TaskDate] is truly a dateTime field then ITER should be one as well.
    DCOUNT does not return a date, Allan. Are you absolutely sure about this?

  5. #5
    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,922
    Oops! D'uh...DCount. That would make it an integer of some sort wouldn't it?

  6. #6
    ajetrumpet is offline VIP
    Windows Vista Access 2007
    Join Date
    Mar 2010
    Location
    N/A
    Posts
    2,694
    Quote Originally Posted by RuralGuy View Post
    Oops! D'uh...DCount. That would make it an integer of some sort wouldn't it?
    Wow! Actually, it returns a variant (via VBA help). Make a note please, two pros on this site are technically incorrect. Hmmm...hope that doesn't get out!

  7. #7
    jonesy29847 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Mar 2010
    Location
    Detroit area
    Posts
    43

    TempVar type casting?

    I worked around the Iter issue, I created a TempVar to hold it, my problem still seems to be the date. I am using TempVar to store date, but the query returns nothing if I use the following.

    Code:
    Between [TempVars]![queryStartDate] And [TempVars]![queryStopDate]

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

Similar Threads

  1. Type Mismatch
    By Alex Motilal in forum Programming
    Replies: 10
    Last Post: 02-13-2011, 05:42 AM
  2. type mismatch in expression
    By lilg1924 in forum Database Design
    Replies: 3
    Last Post: 10-06-2010, 01:37 AM
  3. Type mismatch
    By jgelpi16 in forum Programming
    Replies: 1
    Last Post: 08-07-2010, 06:54 AM
  4. data type mismatch
    By jgelpi16 in forum Programming
    Replies: 5
    Last Post: 08-02-2010, 04:15 PM
  5. Type Mismatch - HELP!
    By jgelpi in forum Programming
    Replies: 3
    Last Post: 07-17-2009, 03:53 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