Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error using RecordSource

Status
Not open for further replies.

cssilver

Technical User
Aug 6, 2000
17
US
I have a report that is opened via a macro. The OnOpen event has the following code:

Me!RecordSource = "SELECT ..." (This is copied from the SQL view of a query)

I keep getting
'Runtime Error 2465:
[My application name] cannot find the field "RecordSource" referred to in your expression'

The dialog box suggests that perhaps I misspelled something or someone has renamed something.

Any ideas why it can't find the RecordSource?
 
You have to open the form in acDesign view, set the recordsource and close, saving the changes. Then open in acNormal view.
 
cssilver,

If the Sql statement doesn't change, just put the statmrnt in the recordsource (in design view) once. The Recordsource property is not usually changed, as it more often is a query. The Query may change (through code manipulation of the querydef object) or by sepping parameter properties of the querfdef. Either of these approaches will allow you to open the report via the macro - without attempting to set the recordsource.

MichaelRed
 
Try using the dot operator instead of the !.
Me.RecordSource = "your sql"
 
That was it! I needed to exchange the ! for a .

Now the next question - I think I'll start a new thread with this as well:

If I want to refer to a field from the SQL stuff in a different part of my code, what is the full reference for it? The query no longer has a name because I copied the sql right into my code.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top