Results 1 to 8 of 8
  1. #1
    Lockrin is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Dec 2009
    Posts
    52

    Data Mismatch?

    I am attempting to make 2 lines visible in on a report based upon if a yes/no field is selected in a table. I am using a DLookup to do this and I am receiving "Runtime error '2471':
    The expression you entered as a query parameter produced this error: 'stFillerID'"

    Here is the exact code I am using

    Private Sub GroupFooter2_Print(Cancel As Integer, PrintCount As Integer)

    Dim stCertNeeded As Boolean
    Dim stFillerID As Long

    stFillerID = Me.FillerOrderLineID
    stCertNeeded = DLookup("[CertRequired]", "tblFillerMetalOrderDetails", "[FillerOrderLineID] = stFillerID")

    If stCertNeeded = False Then
    Me.Line1.Visible = True
    Me.Line2.Visible = True
    Else
    Me.Line1.Visible = False
    Me.Line2.Visible = False


    End If

    Debug.Print stCertNeeded

    End Sub

  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,521
    The variable value needs to be concatenated, and may or may not need single quotes around it depending on the data type of FillerOrderLineID. Info on both here:

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

  3. #3
    Lockrin is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Dec 2009
    Posts
    52
    I have a firm grasp on the DLookup function when the criteria involves a reference to a form, the problem that I am having is that the criteria I need it to lookup is based on the contents of the record on the report. Basically if the "FillerOrderLineID" field is yes I need it to show those 2 lines, otherwise I need them to be invisible.

  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,521
    The technique would be the same. You replace a form reference with either your variable or you can use Me.FillerOrderLineID directly.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    Lockrin is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Dec 2009
    Posts
    52
    What if I don't want to show FillerOrderLineID on the report? I have done it by having it on there and just making it invisible, but that just seems kind of ghetto and not the best way to do it. I am just looking for a more professional way I suppose.

  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,521
    The professional way would probably be to not have the DLookup at all. Can that value be retrieved via joins in the query that underlies the report?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  7. #7
    Lockrin is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Dec 2009
    Posts
    52
    Yes, it is actually in the query that the report is run on. The 2 lines are in the "CertRequired footer" and CertRequired is the field that I want to base it on. How can I base whether or not they are visible on this value? Thank you in advance for you help, it is greatly appreciated.

  8. #8
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Off the top of my head, I think you're stuck with putting it on the report and making it invisible. I just did a brief test and couldn't get the code to recognize the field value otherwise. As you say, it seems like a kludge. I'll play around with it a bit.
    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. Data Mismatch Error
    By sneupane in forum Access
    Replies: 5
    Last Post: 03-15-2010, 08:17 AM
  3. mismatch type compare help needed
    By techexpressinc in forum Queries
    Replies: 3
    Last Post: 02-23-2010, 03:27 PM
  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

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