Solved

2001 Runtime error when setting record source of form

Posted on 2011-02-15
2
392 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
Comment Utility
What is the datatype of [To]?
0
 
LVL 16

Accepted Solution

by:
sjklein42 earned 500 total points
Comment Utility
Maybe str(1) needs to be quoted:

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

Open in new window

0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Text Value from Time 3 23
ms/access subform update with refresh/requery 8 23
Access 2010 3 15
Multiple queries for a form 14 18
The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
In the article entitled Working with Objects – Part 1 (http://www.experts-exchange.com/Microsoft/Development/MS_Access/A_4942-Working-with-Objects-Part-1.html), you learned the basics of working with objects, properties, methods, and events. In Work…
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…

743 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

17 Experts available now in Live!

Get 1:1 Help Now