Error 3252

CedarTree

Registered User.
Local time
Today, 06:48
Joined
Mar 2, 2018
Messages
445
Can't open a form whose underlying query contains a user-defined function that attempts to set or get the form's recordsetclone property.

Just started seeing this error all of a sudden on Access front-end that accesses Access back-end DB and SQL server.

Any suggestions?
 
The function is attempting to find something that doesn't exist yet, or at least hasn't been released for use. In theory, the recordset is defined, but until the Current event, there is no particular guarantee that a record actually exists. I doubt your function cares that the recordset is defined. It probably wants to use it for some purpose that requires it to be ready to expose content, like perhaps using the clone so that you can navigate to a specific record.

You say that you have both an Access BE and an SQL server BE. So... which of those two sources does the form use? The timing for the two cases would differ somewhat in availability. You COULD just use code in the form's _Current event to use the RecordSetClone to navigate for you, but doing from a UDF in a query is, I think, LITERALLY putting the cart before the horse.
 
Do you need the clone method?
ive been writing access code for 20 years and NEVER needed to clone a record set.
 
maybe another fault from MS?
 
I think Richard the doc man is correct in that your form does not yet have a viable object you can use.

The problem I ran into was passing information to a form through custom properties.

The code opening the form would set each custom property to some value or other. Then the form load event would run. I expected the load event would extract the information from the custom properties, but it doesn't work like that! The custom properties do not get set before the form load event runs.

The solution is to add your own public function to the form you are opening, at the appropriate time call your own function and have that do what you want.

I call my particular function fSetUp and I use it in many of my forms.

I blogged about it here along with some explanatory videos:-

 
Do you need the clone method?
ive been writing access code for 20 years and NEVER needed to clone a record set.

@Ranman256 - bound forms AUTOMATICALLY have a .RecordsetClone which you can use, e.g. for navigation. You don't have to make one. It is just there, ready to use - once the form's first _Current event has fired. Before that, the recordset and its clone might not be "ready for prime time." See, for example, the code generated if you use a Combo Box wizard to navigate you to a record selected by the combo. It doesn't create a clone. It uses the already extant .RecordSetClone.
 
You cannot do this inside the RecordSource query. You are trying to make the RecordSource query replace itself while it is open and active. Not happening.
 

Users who are viewing this thread

Back
Top Bottom