Results 1 to 6 of 6
  1. #1
    Scifi67 is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Aug 2012
    Location
    West Sussex. UK
    Posts
    9

    I've Broken Rod's Code - 'Datatype Mismatch' in form event procedure

    Dear All (Especially Rod),

    I've been trying to rewrite my database, hopefully, incorporating Rod's suggestions; from my previous version.
    However, I've broken the VBA code

    When I try to enter a new Examination report, using the form, I get a 'Datatype Mismatch' error.

    I've looked in to everything, the only thing I can see (when it errors), the value of TEPreD; in the code window (when hovering the mouse over it); shows as a time?

    I'm not sure if there's something I'm not understanding with regard to the PK/FK relationship either.
    I think I have checked all the date formats, in the tables, forms & queries.



    The code is supposed to check for and (if present) insert a previously entered date in the field 'TEPreD'

    I would appreciate anyone looking at this and letting me know what I'm missing/doing wrong, please.
    Didn't want to pester Rod directly (I'd need to start paying him a retainer )

    Dave...
    Attached Files Attached Files

  2. #2
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    Quote Originally Posted by Scifi67 View Post
    The code is supposed to check for and (if present) insert a previously entered date in the field 'TEPreD'
    What code? Posting the app is fine, but not giving an explanation and expecting anyone to slog through all of this, trying to reproduce your problem, is not apt to get much help, I'm afraid. You really should always post the errant code here and/or give us some step-by-step instructions on reproducing it.

    Your problem, I think, is not with TEPreD, it's with FleetID. It is defined as a Number, in your underlying Table, but the line

    Code:
    Me.TEPreD = DMax("TEDate", "TblTEDetails", "FleetID = '" & Me.FleetID & "'")


    uses the correct syntax for it as a Text Field! That is the 'type mismatch' error you're receiving. For a Number Field the syntax would be

    Code:
    Me.TEPreD = DMax("TEDate", "TblTEDetails", "FleetID = " & Me.FleetID)
    
    Linq ;0)>

  3. #3
    Scifi67 is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Aug 2012
    Location
    West Sussex. UK
    Posts
    9
    MissingLinq,

    Thank you for looking at this, I will amend the code, tomorrow, when I get back to work.

    My apologies & thanks, also, for your forum pointers; what you have pointed out never occured to me, but makes perfect sense.
    I stripped out everything I could, without breaking functionality; never thought about someone looking through it for the 1st time.

  4. #4
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    Glad to help! Get back to us if you have any further problems!

    Linq ;0)>

  5. #5
    Scifi67 is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Aug 2012
    Location
    West Sussex. UK
    Posts
    9
    Linq,

    Thank you, worked like a charm

  6. #6
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    Glad we could help!

    Linq ;0)>

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

Similar Threads

  1. Replies: 3
    Last Post: 05-07-2012, 12:17 PM
  2. Replies: 1
    Last Post: 07-08-2011, 10:26 AM
  3. datatype mismatch in criteria expression
    By CyberSkillsz in forum Access
    Replies: 1
    Last Post: 06-14-2011, 10:56 AM
  4. Replies: 4
    Last Post: 05-18-2011, 03:24 PM
  5. Replies: 6
    Last Post: 04-24-2010, 11:12 AM

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