Results 1 to 12 of 12
  1. #1
    kavya is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Nov 2018
    Posts
    10

    Error 3075

    I am working in MS Access 2010 and get a run time error 3075 when the SQL statement runs.


    If Me.Combo46.Value = Inspection Then
    WhereClause = ""
    If Not (Me.InspectorFilter = "" Or IsNull(Me.InspectorFilter)) Then
    WhereClause = WhereClause & "AND INDPERS.RacID=""" & Me.InspectorFilter & """ "


    End If
    If Not (Me.DistrictFilter = "" Or IsNull(Me.DistrictFilter)) Then
    WhereClause = WhereClause & "AND County.DistrictLink=" & Me.DistrictFilter & " "
    End If
    If Not (Me.OperatorFilter = "" Or IsNull(Me.OperatorFilter)) Then
    WhereClause = WhereClause & "AND owner.owncontid=" & Me.OperatorFilter & " "
    End If
    If Not (Me.CountyFilter = "" Or IsNull(Me.CountyFilter)) Then
    WhereClause = WhereClause & "AND County.CountyNum=" & Me.CountyFilter & " "
    End If
    If Not (Me.TypeFilter = "" Or IsNull(Me.TypeFilter)) Then
    If ((Me.TypeFilter = "Permanent")) Then
    WhereClause = WhereClause & "AND ADSchedule.ADOwnerPermLoc=True "
    End If
    If ((Me.TypeFilter = "Temporary")) Then
    WhereClause = WhereClause & "AND ADSchedule.ADOwnerPermLoc=False "
    End If
    End If
    If IsNull(Me.Datefrom) Or IsNull(Me.Dateto) Then
    Else
    WhereClause = WhereClause & "([InspDate]>=#" & Me.Datefrom & "# And [InspDate]<=#" & Me.Dateto & "#)"
    End If

    DoCmd.OpenReport "InspReport", acViewPreview, , WhereClause, acWindowNormal
    Me.SetFocus
    DoCmd.Close




    End If

    Need help!

  2. #2
    davegri's Avatar
    davegri is offline Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,740
    Maybe a missing AND
    The added red lines will display the criteria. You can choose the msgbox or debug.print
    Code:
    If Me.Combo46.Value = Inspection Then
    	WhereClause = ""
    	If Not (Me.InspectorFilter = "" Or IsNull(Me.InspectorFilter)) Then
    		WhereClause = WhereClause & "AND INDPERS.RacID=""" & Me.InspectorFilter & """ "
    	End If
    	If Not (Me.DistrictFilter = "" Or IsNull(Me.DistrictFilter)) Then
    		WhereClause = WhereClause & "AND County.DistrictLink=" & Me.DistrictFilter & " "
    	End If
    	If Not (Me.OperatorFilter = "" Or IsNull(Me.OperatorFilter)) Then
    		WhereClause = WhereClause & "AND owner.owncontid=" & Me.OperatorFilter & " "
    	End If
    	If Not (Me.CountyFilter = "" Or IsNull(Me.CountyFilter)) Then
    		WhereClause = WhereClause & "AND County.CountyNum=" & Me.CountyFilter & " "
    	End If
    	If Not (Me.TypeFilter = "" Or IsNull(Me.TypeFilter)) Then
    		If ((Me.TypeFilter = "Permanent")) Then
    			WhereClause = WhereClause & "AND ADSchedule.ADOwnerPermLoc=True "
    		End If
    		If ((Me.TypeFilter = "Temporary")) Then
    			WhereClause = WhereClause & "AND ADSchedule.ADOwnerPermLoc=False "
    		End If
    	End If
    	If IsNull(Me.Datefrom) Or IsNull(Me.Dateto) Then
    	Else
    		WhereClause = WhereClause & "AND ([InspDate]>=#" & Me.Datefrom & "# And [InspDate]<=#" & Me.Dateto & "#)"
    End If
    
    
    debug.print WhereClause
    'MsgBox WhereClause
    
    
    DoCmd.OpenReport "InspReport", acViewPreview, , WhereClause, acWindowNormal
    Me.SetFocus
    DoCmd.Close

  3. #3
    kavya is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Nov 2018
    Posts
    10
    NO, It says syntax error(missing operator) in query expression

  4. #4
    davegri's Avatar
    davegri is offline Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,740
    Is the recordsource for the report a query? Perhaps the problem is in that query.
    Did you try the debug.print? Did the output of that look OK?
    What code line causes the error? Can't help without clues, Dude.

  5. #5
    kavya is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Nov 2018
    Posts
    10
    yes, the record source for the report is a query
    yes, i tried debug.print- it still shows up the same syntax error
    its giving me error with each and every if condition in my code

  6. #6
    davegri's Avatar
    davegri is offline Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,740
    DUDE you are not helping me here. The debug.print wasn't to fix the problem, it was to help diagnose the problem.
    What was the result of the debug.print or msgbox?
    Does the report recordsource query run OK on its own? Last chance.

  7. #7
    GinaWhipp's Avatar
    GinaWhipp is offline Competent Performer
    Windows 7 64bit Access 2013 32bit
    Join Date
    Jul 2011
    Location
    Ohio, USA
    Posts
    377
    Well, the first thing I see is this...

    Code:
    If Me.Combo46.Value = Inspection Then
    ...should be...

    Code:
    If Me.Combo46.Value = "Inspection" Then
    I also see you are not using TEXT deliminators on the values which appear to be TEXT. You should fix that as well.

    Not sure that will fix it. If not then please post the results of Debug.Print as no can run it without the database itself.

  8. #8
    kavya is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Nov 2018
    Posts
    10
    what do you mean by text deliminators?

  9. #9
    GinaWhipp's Avatar
    GinaWhipp is offline Competent Performer
    Windows 7 64bit Access 2013 32bit
    Join Date
    Jul 2011
    Location
    Ohio, USA
    Posts
    377
    See difference below...

    Text = """ & Me.InspectorFilter & """
    Numeric =
    " & Me.DistrictFilter & "

  10. #10
    orange's Avatar
    orange is offline Moderator
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,870
    kavya,

    This "what do you mean by text deliminators" indicates a lack of basic familiarity with Access VBA. It would help you and readers if you could put your post/question into context.
    Tell us in simple terms WHAT you are trying to do and readers will offer suggestions as to HOW it might be accomplished.
    It might be more efficient if you also attached a copy of your database in zip format.
    Good luck with your project.

  11. #11
    isladogs's Avatar
    isladogs is offline Access MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    6,204
    Of course 'text deliminators' should really read 'text delimiters'
    Colin Riddington, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I know I don't know, I keep quiet!

  12. #12
    GinaWhipp's Avatar
    GinaWhipp is offline Competent Performer
    Windows 7 64bit Access 2013 32bit
    Join Date
    Jul 2011
    Location
    Ohio, USA
    Posts
    377
    Oops, so much for spell check but that is a word so...

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

Similar Threads

  1. Replies: 2
    Last Post: 01-04-2016, 09:40 AM
  2. Replies: 2
    Last Post: 09-10-2014, 11:30 AM
  3. Replies: 11
    Last Post: 05-01-2014, 11:56 AM
  4. Replies: 3
    Last Post: 03-05-2013, 11:17 AM
  5. Replies: 6
    Last Post: 05-30-2012, 12:32 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