Solved

Access 2010 Run-Time Error 3075

Posted on 2014-10-10
6
224 Views
Last Modified: 2014-10-10
I'm using the code below and get error code 3075 -- Syntax error (missing operator) in query expression '[Budgetary_Dr]='(4287001',45900001'). Any Thoughts

Dim strList As String


strList = "('" & Replace(Me.Budgetary_DR, " ", "','") & "')"

If DCount("*", "tbl_USSGL", "[Budgetary_DR]='" & strList & "'") = 0 Then
     MsgBox "No related record found", vbExclamation, "ATM"
     Exit Sub
 Else
End If
DoCmd.OpenForm "frm_USSGL", , , "[USSGL Child] In " & strList
0
Comment
Question by:shieldsco
  • 2
  • 2
  • 2
6 Comments
 
LVL 22

Expert Comment

by:rspahitz
ID: 40373439
Looks like the quotes are mis-aligned:

'[Budgetary_Dr]='(4287001',45900001')

maybe this?

[Budgetary_Dr]='(4287001,45900001)'
?

To help out, just before the DoCmd, put this:

Debug.Print strList

And you can look in the Immediate window (open from the View menu) and you'll see the value.
Or set a breakpoint there and examine strList to ensure that it's correct.
0
 
LVL 22

Expert Comment

by:rspahitz
ID: 40373453
Another thought is to take the DCount, DCount("*", "tbl_USSGL", "[Budgetary_DR]='" & strList & "'")
And turn it into a query to make sure it works, something like:

SELECT * from tbl_USSGL
WHERE [Budgetary_DR]=' {contents of strList} '

test that in the query builder
0
 
LVL 119

Expert Comment

by:Rey Obrero
ID: 40373537
first check strList values to be in this format

'4287001','45900001'

values are wrapped in single quotes (')

then use this syntax

If DCount("*", "tbl_USSGL", "[Budgetary_DR] In (" & strList & ")") = 0 Then


----

DoCmd.OpenForm "frm_USSGL", , , "[USSGL Child] In (" & strList & ")"
0
Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

 
LVL 119

Accepted Solution

by:
Rey Obrero earned 500 total points
ID: 40373601
correction..

strList = "('" & Replace(Me.Budgetary_DR, " ", "','") & "')"
'add the line below to check the format of strList

debug.print strList

the result should be

('4287001','45900001')

so change the syntax i posted above with

If DCount("*", "tbl_USSGL", "[Budgetary_DR] In " & strList) = 0 Then

----

DoCmd.OpenForm "frm_USSGL", , , "[USSGL Child] In " & strList
0
 

Author Comment

by:shieldsco
ID: 40373657
Rey - run time error 2471 The expression you entered as a query parameter produced tis error: '[Budgetary_DR]''

If DCount("*", "tbl_USSGL", "[Budgetary_DR] In " & strList) = 0 Then
0
 

Author Closing Comment

by:shieldsco
ID: 40373701
Very Good
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.

943 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

1 Experts available now in Live!

Get 1:1 Help Now