Code to refresh form details after adding data in different form?

oZone

Registered User.
Local time
Today, 03:47
Joined
Oct 17, 2008
Messages
103
I have a DB that allows the user to add data using several forms but am having a problem...

In my main form (MovieDetails) I have a command button that opens up another form which let's the user add new actors to the DB but after adding the data, if I go back to the main form (still open), it does not reflect that change. It only shows the updated data if I close the form then reopen it.

I was told by a friend that I can have the form auto update, or refresh itself using VB code, but he didn't know how...

Can someone here provide an example of how to do this?:confused:

Thanks!
 
See your original post (I posted the answer there just a minute ago).
 
oh, did I already ask that question? Sorry, my bad...:p

I'll check now, thanks.:o
 
I added the info you suggested to my AddStars form, but after adding a star I get this error message:

Video Library cant find the form frmMovieDetailsSubform referred to in a macro expression or Visual Basic code.

The AddStars form is seperate from the main form (frmMovieDetails), the combo box that needs to be updated with the new star data is in a subform (frmMovieDetailsSubform) within the main form. Maybe this is why it didnt work? I dont know, but I double checked the subform name in the VB code, it is correct.

Help?:confused:
 
I added the info you suggested to my AddStars form, but after adding a star I get this error message:



The AddStars form is seperate from the main form (frmMovieDetails), the combo box that needs to be updated with the new star data is in a subform (frmMovieDetailsSubform) within the main form. Maybe this is why it didnt work? I dont know, but I double checked the subform name in the VB code, it is correct.

Help?:confused:

See the first screenshot on this tutorial on my website:
http://www.btabdevelopment.com/main...rhowtoreferencesubforms/tabid/76/Default.aspx
You need the name of the subform CONTAINER, not the subform itself.
 
I read your article, but I'm affraid it's a bit over my head being a beginner... I've only been learning Access for a little under 3 months now, and am not very familiar with VB, but am trying...

This is the furthest I got with your article, but it still gives me an error so I'm sure theres something wrong with it:

Code:
Forms("frmMovieDetails").Controls("frmMovieDetailsSubform").Form.Controls("cboAddStarToMovie").Requery
I'm sort of lost at the moment, unsure what to do to get it working. Any help would be appreciated, thanks.
 
The idea was to just look at the screenshot to figure out how to find out what the subform container control name is (not the subform name) because you reference that container name instead of the actual subform name.
 
You need the requery, do it like this under the command "After update" of "form_Close"

Code:
forms!frmMovieDetails.form.frmMovieDetailsSubform.form.cboAddStarToMovie.requery
Or just reload the whole (sub)form
Code:
forms!frmMovieDetails.form.frmMovieDetailsSubform.requery
 
Code:
forms!frmMovieDetails.form.frmMovieDetailsSubform.form.cboAddStarToMovie.requery
Vinzz:
That is erroneous code. You don't need two .form parts in there. You ONLY need the one after the subform container control. The only time you would use .form more than once is if you are referring to a subform within another subform.
 

Users who are viewing this thread

Back
Top Bottom