Solved

2001 Runtime error when setting record source of form

Posted on 2011-02-15
2
395 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 500 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

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

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

It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
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…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

828 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