473,327 Members | 1,919 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

refresh subform after adding records to related table

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].Requery

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
2 2493
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()
MeetingSubID.Requery
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
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;

Forms("MainFormName").[frmSubFrmName].Form.Requery

And you are laughing.

Regard

Richard
Nov 12 '07 #3

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

Similar topics

3
by: Jason | last post by:
I am trying to filter records in a primary form based on records in related tables. The data in the related tables is being displayed in the primary form through subforms. To be more specific, I...
6
by: Ray | last post by:
I have a main form with a subform. The main form has a combo box which lists all the clients which in turn are displayed in the subform. The subform is bound to the combo box and all work well....
5
by: Mary Litten | last post by:
Hi - (This is my very first post) I have gotten to this point of registering to post because I have been spinning my wheels so long, I believe I am all caught up in the weeds. (and mud) I have...
25
by: Lyn | last post by:
Hi, I am working on a genealogy form. The only table (so far) lists everybody in the family, one record per person. Each record has an autonum ID. The parent form (frmMainForm) displays the...
0
by: P Mitchell | last post by:
Hello I would like someone to be able to help with the updating of data in a lookup list in a subform. In short, is their a VB instruction that is the equivalent of performing the action of...
4
by: Dave Boyd | last post by:
Hi, I have two very similar forms each with a subform. The main form gets a few fields from the user and passes this back to a query that the subform is bound to. The requery is done when the...
5
by: tdmailbox | last post by:
I have a form with a child form. In the child form there is a list of names that can grow quite large. On the parent form I want to display the first name from the child form. I set up a test...
1
by: phaddock4 | last post by:
Being fairly inexperienced at Access 2000, i've been reading many posts here for the last several days, and testing myself to find the best approach to do the following in A2K: SET UP: I have...
9
by: Ecohouse | last post by:
I have a main form with two subforms. The first subform has the child link to the main form identity key. subform1 - Master Field: SK Child Field: TrainingMasterSK The second subform has a...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.