Change SourceObject for Subform after popup is closed

vapid2323

Scion
Local time
Yesterday, 20:46
Joined
Jul 22, 2008
Messages
217
Hey guys

I change a subforms SourceObject so that a popup can be used to edit the records or add new ones. This works with the following code.

Me.subfrmQualObservations.SourceObject = ""

Now I want to close the popup and repopulate that subform, I thought the 'On Got Focus' event would do it but for some reason its not....

Any idea where the code below should go in order to get that subform to show back up?

Me.subfrmQualObservations.SourceObject = "subfrmQualObservations"
 
its a bang isnt it? subfrmqualobservations is then ame of the control on the main form, not the name of the subform.

Me!subfrmQualObservations.SourceObject = "subfrmQualObservations"

or maybe you need the form qualifier to get at the subform itself

Me!subfrmQualObservations.form.SourceObject = "subfrmQualObservations"
 
its a bang isnt it? subfrmqualobservations is then ame of the control on the main form, not the name of the subform.

Me!subfrmQualObservations.SourceObject = "subfrmQualObservations"

or maybe you need the form qualifier to get at the subform itself

Me!subfrmQualObservations.form.SourceObject = "subfrmQualObservations"

Thanks for the help but right now I cant even get the On Got Focus event to run.

It might have to do with my setup this is the drilldown of my forms, I have a mainform that wraps the entire database as a navigation type tool and then I just change the subforms as the user changes menu options. That makes the subform I want to change 3 deep.

Mainform -> Subform1 -> subfrmQualObservations
 
I am trying to add this to a exit command button on the popup and I have tried

Code:
Forms!frmMain_toplg!SubForm1.subfrmQualObservations.SourceObject = "subfrmQualObservations"

And

Forms!frmMain_toplg!SubForm1.Form.subfrmQualObservations.SourceObject = "subfrmQualObservations"

With no luck, I also dont get an error so I am not sure what to do with this...
 
save your data to the main form/sub form before you close the popup one.
and you must make sure that your new data will not be using anything from the subform (once it's closed this data is gone)
 
I change a subforms SourceObject so that a popup can be used to edit the records or add new ones. This works with the following code.
I just wonder why you're needing to do this. It sounds to me that you're doing this because you're getting a "write conflict" error message? If this is the case then you can:

* use a query as the Record Source of both the main form and the pop-up form.

OR

* make the pop-up form unbound and on the Unload event of this pop-up form pass the values back to the main form
 
The error I am getting is that my table is already opend exclusively by another user.

I changed the record source to a qry and I get the same error message unless I run the following before I open the popup.

Also I try to add the code to the unload event with no luck.

Code:
Me.subfrmQualObservations.SourceObject = ""

Smig thanks for your tip, but I think its already being saved as both the popup and subform work with the same table. So after I manualy reload the subform with my command button. all my data shows.

So unless I misunderstood we are still working with the first issue.

I know for a fact that if i run the following code in my form (with a cmd button) I can get the subform to showback up with the correct datasource.
Code:
Me.subfrmQualObservations.SourceObject = "subfrmQualObservations"
 
I changed the record source to a qry and I get the same error message unless I run the following before I open the popup.
Did you change the record source of your main form, the subform and the pop-up form?

What about using the unbound form solution?
 
Did you change the record source of your main form, the subform and the pop-up form?

What about using the unbound form solution?

The main form works on a different query but yes the popup and the subform both have the same query as a record source.

I guess I dont understand the unbound option very well, wont that still have the same problem as it still access the same records?

I am trying to figure out how to set it up right now via google (never had to do one before) but I will let you know how it works out.
 
You can upload your db and I'll have a quick look and advise what's going on. Indicate the forms in concern too.

It's unbound so it won't affect any table. It's just simply setting the value from the controls on the unbound form to the fields in the main form. E.g.:
Code:
Forms!MainForm![Field] = Me.ControlName

This you do in the Unload event of the unbound pop-up form.
 
I don’t have rights to distribute all the code, so uploading is hard to do

I really do appreciate the assistance and I will try to get this unbound option working.
 

Users who are viewing this thread

Back
Top Bottom