Solved

2001 Runtime error when setting record source of form

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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

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

A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

832 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