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

x
?
Solved

2001 Runtime error when setting record source of form

Posted on 2011-02-15
2
Medium Priority
?
403 Views
Last Modified: 2012-05-11
Hello,

I am getting a runtime error of '2001' Previous operation canceled when I attempt to set the record source of a form at run time.  This is in Access 97.  I suspect the where clause is causing the problem as "SELECT * FROM qryFrmVariancesSource" seems to be working fine.  Could someone take a look.  Thanks.
Dim str As Variant
 
    Dim strArgs As String
   
    strArgs = Me.OpenArgs
    MsgBox strArgs
    str = MySplit(strArgs, ";")
    
    'Debug.Print str(1) & vbTab & str(2)
'Debug.Print "SELECT * FROM qryFrmVariancesSource WHERE TO = " & str(1)
Me.RecordSource = "SELECT * FROM qryFrmVariancesSource WHERE [TO] = " & str(1)

Open in new window

0
Comment
Question by:chtullu135
2 Comments
 
LVL 77

Expert Comment

by:peter57r
ID: 34897255
What is the datatype of [To]?
0
 
LVL 16

Accepted Solution

by:
sjklein42 earned 2000 total points
ID: 34897287
Maybe str(1) needs to be quoted:

Me.RecordSource = "SELECT * FROM qryFrmVariancesSource WHERE [TO] = '" & str(1) & "'"

Open in new window

0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
We live in a world of interfaces like the one in the title picture. VBA also allows to use interfaces which offers a lot of possibilities. This article describes how to use interfaces in VBA and how to work around their bugs.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

927 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