Error 3071 :( line no 3 help me out

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Karishma2194
    New Member
    • Jun 2014
    • 3

    Error 3071 :( line no 3 help me out

    Code:
    Private Sub cmdSearch_Click()
      On erorr GoTo errr
      Me.FG_subform.Form.RecordSource = "SELECT * FROM FG " & BuildFilter
      Me.FG_subform.Requery
      Exit Sub
    errr:
     MsgBox Err.Description
    End Sub
    Private Function BuildFilter() As Variant
      Dim varWhere As Variant
      Dim tmp As String
      tmp = ""
      Const conJetDate = "\#dd\/mm\/yyyy\#"
      varWhere = Null
      If Me!SerialNumber > "" Then
      varWhere = varWhere & "[Serial Number] = " & Me!SerialNumber & " AND "
      End If
      If Me!MacID > "" Then
      varWhere = varWhere & "[Mac ID] = " & Me!MacID & " AND "
      End If
      If Me!InwardDatefrom > "" Then
      varWhere = varWhere & "([Inward Date] >= " & Format(Me!InwardDatefrom, conJetDate) & ") AND "
      End If
      If Me!InwardDateto > "" Then
      varWhere = varWhere & "([Inward Date] <= " & Format(Me!InwardDateto, conJetDate) & ") AND "
      End If
      If Me!InwardSiteCode > "" Then
      varWhere = varWhere & "[Inward Site Code] = " & Me!InwardSiteCode & " AND "
      End If
      If Me!InwardSiteName > "" Then
      varWhere = varWhere & "[Inward Site Name] = " & tmp & Me!InwardSiteName & tmp & " AND "
      End If
      If Me!InwardZone > "" Then
      varWhere = varWhere & "[Inward Zone] = " & tmp & Me!InwardZone & tmp & " AND "
      End If
      If Me!NameofEngineer > "" Then
      varWhere = varWhere & "[Name of Engineer] = " & tmp & Me!NameofEngineer & tmp & " AND "
      End If
      If Me!DrishtiTicket > "" Then
      varWhere = varWhere & "[Drishti Ticket (If Applicable)] = " & Me!DrishtiTicket & " AND "
      End If
      If Me!IMACDID > "" Then
      varWhere = varWhere & "[IMACD ID (If Applicable)] = " & Me!IMACDID & " AND "
      End If
      If Me!AssetTagNo > "" Then
      varWhere = varWhere & "[Asset Tag Number] = " & Me!AssetTagNo & " AND "
      End If
      If Me!ArticleNo > "" Then
      varWhere = varWhere & "[Article No] = " & Me!ArticleNo & " AND "
      End If
      If Me!Category2 > "" Then
      varWhere = varWhere & "[Category2 (Asset Description)] = " & Me!Category2 & " AND "
      End If
      If Me!Category3 > "" Then
      varWhere = varWhere & "[Category3 (Make)] = " & Me!Category3 & " AND "
      End If
      If Me!OutwardSiteCode > "" Then
      varWhere = varWhere & "[Outward Site Code] = " & Me!OutwardSiteCode & " AND "
      End If
      If Me!OutwardSiteName > "" Then
      varWhere = varWhere & "[Outward Site Name] = " & Me!OutwardSiteName & " AND "
      End If
      If Me!OutwardZone > "" Then
      varWhere = varWhere & "[Outward Zone] = " & Me!OutwardZone & " AND "
      End If
      If Me!OutwardDatefrom > "" Then
      varWhere = varWhere & "([Outward Date] >= " & Format(Me!OutwardDatefrom, conJetDate) & ") AND "
      End If
      If Me!OutwardDateto > "" Then
      varWhere = varWhere & "([Outward Date] <= " & Format(Me!OutwardDateto, conJetDate) & ") AND "
      End If
      If IsNull(varWhere) Then
      varWhere = ""
      Else
      varWhere = "WHERE " & varWhere
      If Right(varWhere, 5) = " AND " Then
      varWhere = Left(varWhere, Len(varWhere) - 5)
      End If
      End If
      BuildFilter = varWhere
      End Function
  • manageknowledge
    New Member
    • Jun 2014
    • 10

    #2
    What is the value of BuildFilter?
    SQL query needs to end with ";" as well.

    Comment

    • Stewart Ross
      Recognized Expert Moderator Specialist
      • Feb 2008
      • 2545

      #3
      Not enough information supplied to be anything other than a guess. Your On Error statement is mis-spelled at line 2

      On erorr GoTo

      and your procedure will fail compilation. That statement should be

      On Error Goto

      If this is just a typo you have introduced when asking your question please consider carefully what you need to ask and why you need to be accurate about what you post.

      -Stewart

      Comment

      • Karishma2194
        New Member
        • Jun 2014
        • 3

        #4
        actually hav only little knoweledge about vba n i copy it from a site

        Comment

        • Stewart Ross
          Recognized Expert Moderator Specialist
          • Feb 2008
          • 2545

          #5
          We've gone as far as we can to assist on the little information that is provided.

          -S

          Comment

          • Karishma2194
            New Member
            • Jun 2014
            • 3

            #6
            okk tell me what kind of information u want?

            Comment

            • anvidc
              New Member
              • Sep 2007
              • 28

              #7
              Try use String instate of Variant

              Comment

              • twinnyfo
                Recognized Expert Moderator Specialist
                • Nov 2011
                • 3653

                #8
                Line 14: you set varWhere = Null, but then in line 16, you set varWhere = varWhere & etc.

                You cannot concatenate null values.

                But, other than that, I am with the rest. Wxactly what is it that you need help on?

                Comment

                • NeoPa
                  Recognized Expert Moderator MVP
                  • Oct 2006
                  • 32633

                  #9
                  Originally posted by Karishma
                  Karishma:
                  okk tell me what kind of information u want?
                  Please read a full explanation of how to write a question (How to ask "good" questions -- READ BEFORE SUBMITTING A QUESTION!) so that we have a chance of helping you. You'll find this as a sticky thread at the top of the Access Answers forum.

                  Comment

                  Working...