Solved

2001 Runtime error when setting record source of form

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

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

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

Today's users almost expect this to happen in all search boxes. After all, if their favourite search engine juggles with tens of thousand keywords while they type, and suggests matching phrases on the fly, why shouldn't they expect the same from you…
I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
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…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

867 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

16 Experts available now in Live!

Get 1:1 Help Now