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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Setting a form's recordset from another form - sudden error

Status
Not open for further replies.

biot023

Programmer
Nov 8, 2001
403
GB
I was happily opening a form from another in my code & setting its RecordSource, and everything was working fine.
All of a sudden, I'm getting error message 40036 telling me
Method 'item' of object 'Forms' failed.

the code is like:

DoCmd.RunMacro "open_indexer"

Forms!indexer.RecordSource="SELECT * FROM a_table;"

Like I say, this WAS working, but now I can't get it to work even after I've removed all of the code I put in since before it stopped working.

I'm utterly stumped!

Douglas. If it don't make you laugh, it ain't true.
 
I think maybe it is because the openform macro I use has not finished opening the form when I try to call the following code.
Does anyone know a way around this?

Douglas JL If it don't make you laugh, it ain't true.
 
biot023,

Did you ever solve this problem?

I'm getting the same thing, but it isn't a matter of the OnLoad/OnOpen event not being finished. The error occurs even when I'm in debug mode and the target form is already open. _________
Rott Paws

...It's not a bug. It's an undocumented feature!!!
 
try/look into

do events

or try converting the macro to code and doing it all by code...

just a couple idea's...

--James
junior1544@jmjpc.net
Life is change. To deny change is to deny life.
 
Do events? What would that do? Where should I put it?

I am already doing it in code. . . . Here's what I'm trying to do:

I've got a form that already has a bunch of automation in it. I now want to open it from a new form and trigger some of the automation. When the user clicks a command button on new form, I open the existing form through code (docmd.openform...).

Next I would like to launch a procedure in the old form from the code in the new form.

The target form procedure that I want to call is
Public Sub cmdExport_Click

Any ideas?

_________
Rott Paws

...It's not a bug. It's an undocumented feature!!!
 
Hello - I can't remember how (or if) I got round the problem, but one thing I do as standard, now (although it isn't pretty) is have a setup() function for each form of this kind. This way, I can open the form, wait a little if necessary, & then just call the function.
I've stopped bothering with OnOpen et al. all together.
Perhaps a little lazy, but I get the distinct impression that Access isn't half as procedural as it might like to claim...

Douglas JL

If it don't make you laugh, it ain't true.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top