Running Parameter Query Via A Form and Encountering Problems

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • elak6
    New Member
    • Nov 2011
    • 21

    Running Parameter Query Via A Form and Encountering Problems

    I am trying to run the query below, but i keep on getting syntax error in query expression.
    I dont know exactly what i have done wrong and any help to put me on the right path will be very much appreciated

    Code:
    SELECT TESTER.[Internal Part Number], TESTER.Type, TESTER.[Part Type], TESTER.[RoHS Compliant], TESTER.[Termination Finish], TESTER.[Surface Mount], TESTER.[Pk Reflow Temp (Cel)], TESTER.MSL, TESTER.[JESD-97 Code], TESTER.Revision, TESTER.Description, TESTER.[Requested Manufacturer], [TESTER].[Requested Part Number], TESTER.YTEOL, TESTER.[Life Cycle Stage], TESTER.[Board Name], TESTER.[Project Name], TESTER.Comments, TESTER.[Record Added Date]
    FROM TESTER
    WHERE (((Nz([TESTER.[Internal Part Number]],'')) Like Nz(Forms!dashboard![Internal Part Number],'*')) And ((Nz([TESTER.[Part Type]],'')) Like Nz(Forms!dashboard![Part Type],'*')) And ((Nz([TESTER.Type],'')) Like Nz(Forms!dashboard!Type,'*')) And ((Nz([TESTER.[RoHS Compliant]],'')) Like '*' & Nz(Forms!dashboard![RoHS Compliant],'*') & '*') And ((Nz([TESTER.[Termination Finish]],'')) Like Nz(Forms!dashboard![Termination Finish],'*')) And ((Nz([TESTER.Revision],'')) Like Nz(Forms!dashboard!Revision,'*')) And ((Nz([TESTER[.Requested Manufacturer]],'')) Like Nz(Forms!dashboard![Manufacturer Name],'*')) And ((Nz([[TESTER].[Requested Part Number]],'')) Like Nz(Forms!dashboard![Manufacturer Part Number],'*')) And ((Nz([TESTER.[Life Cycle Stage]],'')) Like Nz(Forms!dashboard![Life Cycle Stage],'*')) And ((Nz([TESTER.[Board Name]],'')) Like Nz(Forms!dashboard![Board Number & Revison],'*')));
    ;
  • NeoPa
    Recognized Expert Moderator MVP
    • Oct 2006
    • 32645

    #2
    If you were to tidy the SQL code up before posting (so that it's more than just words vomited together by some system - and readable), then you'd probably have noticed some of the problems yourself.

    Try the following and see what you get :
    Code:
    SELECT [Internal Part Number]
         , [Type]
         , [Part Type]
         , [RoHS Compliant]
         , [Termination Finish]
         , [Surface Mount]
         , [Pk Reflow Temp (Cel)]
         , [MSL]
         , [JESD-97 Code]
         , [Revision]
         , [Description]
         , [Requested Manufacturer]
         , [TESTER].[Requested Part Number]
         , [YTEOL]
         , [Life Cycle Stage]
         , [Board Name]
         , [Project Name]
         , [Comments]
         , [Record Added Date]
    FROM   [TESTER]
    WHERE ((Nz([Internal Part Number],'') Like Nz(Forms!dashboard![Internal Part Number],'*'))
      AND  (Nz([Part Type],'') Like Nz(Forms!dashboard![Part Type],'*'))
      AND  (Nz([Type],'') Like Nz(Forms!dashboard!Type,'*'))
      AND  (Nz([RoHS Compliant],'') Like '*' & Nz(Forms!dashboard![RoHS Compliant],'*') & '*')
      AND  (Nz([Termination Finish],'') Like Nz(Forms!dashboard![Termination Finish],'*'))
      AND  (Nz([Revision],'') Like Nz(Forms!dashboard!Revision,'*'))
      AND  (Nz([Requested Manufacturer],'') Like Nz(Forms!dashboard![Manufacturer Name],'*'))
      AND  (Nz([Requested Part Number],'') Like Nz(Forms!dashboard![Manufacturer Part Number],'*'))
      AND  (Nz([Life Cycle Stage],'') Like Nz(Forms!dashboard![Life Cycle Stage],'*'))
      AND  (Nz([Board Name],'') Like Nz(Forms!dashboard![Board Number & Revison],'*')))

    Comment

    • elak6
      New Member
      • Nov 2011
      • 21

      #3
      Hi NeoPa,

      Thanks for helping me realise my errors
      The code runs perfectly now :)
      Thanks for all your help,
      Really appreciate

      Regards,
      elak6
      Last edited by elak6; Mar 6 '12, 10:16 AM. Reason: Solved the problem, Thanks

      Comment

      • NeoPa
        Recognized Expert Moderator MVP
        • Oct 2006
        • 32645

        #4
        That format is a good one for a predefined QueryDef where you want it to handle anything entered, as well as to allow for items to remain unspecified. If you're building the SQL up in your VBA code though, it's easier to include them only if they're required (which you can determine before you create the SQL).

        Comment

        Working...