Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Access 2010 Run-Time Error 3075

Posted on 2014-10-10
6
Medium Priority
?
249 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 120

Expert Comment

by:Rey Obrero (Capricorn1)
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
NEW Veeam Backup for Microsoft Office 365 1.5

With Office 365, it’s your data and your responsibility to protect it. NEW Veeam Backup for Microsoft Office 365 eliminates the risk of losing access to your Office 365 data.

 
LVL 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 2000 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
Suggested Courses

916 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