By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
461,995 Members | 505 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 461,995 IT Pros & Developers. It's quick & easy.

refresh subform after adding records to related table

P: 7
I have a command button on the main form of my database that allows users to add new records. But, even though new records get added to the sub table when I click on the button, those new records arenít immediately reflected in the combo box that is on the subform (whose record source is a junction table).

Do you know of any methods I can add in an event procedure to update the subform? I added the following code based on a suggestion I read on another post:

- Command button is called "AddAuthor"
- Command button adds new records (Authors) to "frmAuthors"
- Combo box that I want to refresh is found on subform "frmCiteAuthors"

Private Sub AddAuthor_Exit(Cancel As Integer)

DoCmd.Close acForm, "frmAuthors"
Dim varBookmark As Variant

varBookmark = Forms![frmCiteAuthors].Bookmark

Forms![frmCiteAuthors].Bookmark = varBookmark

I get an error message that Access can't find the form frmCiteAuthors. I tried taking the form name out of brackets so that it looked like this:

Forms!frmCiteAuthors.Bookmark = varBookmark

but that didn't change anything .

What am I doing wrong? What code should I be using?

Thanks for your help.
Oct 4 '07 #1
Share this Question
Share on Google+
2 Replies

P: 11
I had the same problem so what I did was this:

in the subform I updated to Requery the OnFocus property of the control I wanted to be refreshed (so that instead of showing all records, it would show only the records related to the data entered in the main form):

Private Sub MeetingSubID_GotFocus()
End Sub

So if in the main form I entered a new Meeting when I clicked the MeetingSubID textfield in the subform (in order to add details to the meeting, such as as many participants as I wish) it was automatically updated, as it was linked to the main form in Row Source through the query

SELECT Meetings.MeetingSubID FROM Meetings WHERE (((Meetings.MeetingSubID)=Forms![Add Meetings]!MeetingID));

* Meetings is the Subform/table
* Add Meetings is the Main Form/table
* Meetings.MeetingSubID is the Child field
* Add Meetings!MeetingID is the Master field
Oct 15 '07 #2

P: 3
I have found a way to fix the Not find form. You need to reference the Main Form the sub form is coming of like this;


And you are laughing.


Nov 12 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.