Results 1 to 6 of 6
  1. #1
    jgelpi16 is offline Expert
    Windows XP Access 2007
    Join Date
    Mar 2010
    Location
    Charlotte, NC
    Posts
    544

    Question data type mismatch


    I have looked at this code 1000 times and cannot discern why I am getting the error. My table has both fields I am referencing to defined as a long integer. The form returns a whole number every time.

    Code:
    Dim varDenSelect
    Dim varOfferID
    varOfferID = Forms![frmNon-Corpofferinformation].OfferID.Value
    varDenSelect = DLookup("[DenSelect]", "DenialReason", "[OfferID] = '" & varOfferID & "'")
    frameDenialOptions.Value = varDenSelect
    Thank you for your help in advance!

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    If OfferID is a numeric data type you have the syntax wrong:

    DLookup Usage Samples
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    jgelpi16 is offline Expert
    Windows XP Access 2007
    Join Date
    Mar 2010
    Location
    Charlotte, NC
    Posts
    544
    Ok, thanks for the link....However, I am getting a new error now...

    "The expression you entered as a query parameter produced this error: 'varOfferID'"

    Code:
    Dim varDenSelect
    Dim varOfferID
    varOfferID = Forms![frmNon-Corpofferinformation].OfferID.Value
    varDenSelect = DLookup("[DenSelect]", "DenialReason", "[OfferID] = varOfferID")
    frameDenialOptions.Value = varDenSelect

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    You need to concatenate the variable value, similar to how the link handled form references. Just substitute your variable for the form reference.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    jgelpi16 is offline Expert
    Windows XP Access 2007
    Join Date
    Mar 2010
    Location
    Charlotte, NC
    Posts
    544
    Perfect, thank you.

    As a side note. Thank you for providing the links and making me do the reading. Helps me retain information better.

  6. #6
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    Happy to help, and thanks for appreciating the method. I do try to "teach how to fish" rather than give fish.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Type mismatch in expression /Query
    By Brian62 in forum Queries
    Replies: 4
    Last Post: 04-22-2010, 10:00 AM
  2. mismatch type compare help needed
    By techexpressinc in forum Queries
    Replies: 3
    Last Post: 02-23-2010, 03:27 PM
  3. Replies: 4
    Last Post: 10-26-2009, 05:27 AM
  4. Type Mismatch - HELP!
    By jgelpi in forum Programming
    Replies: 3
    Last Post: 07-17-2009, 03:53 PM
  5. Replies: 4
    Last Post: 05-16-2009, 09:17 PM

Tags for this Thread

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