473,406 Members | 2,281 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,406 software developers and data experts.

Subform won't update on parent form, but will elsewhere

Hi,
I've built a sequence that works thusly:
User chooses a value from a combo box. This causes a query to run displaying records with a field value matching the combo box in subform 1. Then, the record ID of whichever record is active in subform 1 is used to populate a text box. This text box has its after update property enabled that runs a second query which should populate a second form by matching the record id to entries in a many-to-many junction table. Everything works fine, but the second subform (which is visible on a main form with subform 1) doesn't update. If I open form 2 (which is what subform 2 is based on)from the navigation panel, it contains the correct records based on the record ID from the textbox. When I press f9, subform 2 on the main form will populate with the correct records from the first entry in subform 1, but will not populate correctly if I select any other entry in subform 1 and press f9. The textbox value changes correctly according to the entry selected in subform 1 and form 2 always contains the correct records when opened from the navigation panel after selecting different entries in subform 1. Any ideas? Sorry about the ramble.

Thanks,
Bob
Aug 2 '10 #1
7 4073
I stuck a msgbox in the afterupdate event of the text box control and it didn't come up, so I'm assuming this code isn't executing at all. The textbox gets it value through this:
Expand|Select|Wrap|Line Numbers
  1. =[Requests_Query].Form![Request Number]
and this is the code in the update event property:
Expand|Select|Wrap|Line Numbers
  1. Private Sub Text_AfterUpdate()
  2. Dim RSQQueryName As String
  3. MsgBox ("sux")
  4. RSQQueryName = "Request_Skills_Query"
  5.  
  6. 'I think you must have this line to save the record, first
  7. DoCmd.RunCommand acCmdSaveRecord
  8.  
  9. 'Then execute the query
  10. DoCmd.OpenForm RSQQueryName
  11.  
  12.  
  13. End Sub
I've tried the Dirty and Change properties also, but nothing. Can anyone help?
Aug 2 '10 #2
NeoPa
32,556 Expert Mod 16PB
Sorry Bob. I couldn't work out what the situation was. Communication is always so important. I'm afraid your post was pretty unclear.
Aug 2 '10 #3
The basic problem is that I have a subform (subform 2) which doesn't update. Subform 2 is based on a query. The query uses a textbox to capture the active record number from subform 1. I tried to use the afterupdate property of the textbox to run the query when the active record in subform 1 changes. But apparently the afterupdate property is not working properly because I stuck a msgbox in there and it didn't pop up (see code above). Although the msgbox doesn't pop up, the query does change - I can see this by opening the query from the navigation panel. Why won't subform 2 update even though the underlying query updates? Why won't the msgbox appear? Is the afterupdate event not occuring?
Aug 2 '10 #4
NeoPa
32,556 Expert Mod 16PB
I'm sorry Bob, but almost all the questions you ask depend on my knowing your database much better than I can from your explanations (which are themselves mainly references to things I know nothing of). I'm going to see if I can make some intelligent guesses as to where you're coming from.

I expect you are looking to run some code in the OnCurrent event. I'm not sure whether this would be for the main form or simply the other subform. AfterUpdate() only fires when relevant data has been changed by the operator.

When you want to rerun the query in the second subform ([Subform 2]) you need to call the form's .Requery method. See Referring to Items on a Sub-Form for how to handle items on different subforms etc.
Aug 2 '10 #5
Thanks for the help, maybe I can provide a little more clarification. Both subforms are unbound. The records in subform 2 should change depending on which record in subform 1 is active. I tried to accomplish this by using a textbox as an intermediary to capture the active record number from subform 1 (the requests_query subform in the code above). A query then runs based on the changing active record number of subform 1 captured in the textbox; I tried to trigger the query using the afterupdate event of the textbox. Subform 2 should then be updated based on the new results of the query. But subform 2 doesn't update. My guess is that none of the event triggers for the textbox are working, since I've tried OnChange and OnDirty as well and nothing works. I've also used .Requery in line 10 above instead of .OpenForm. Still - nothing.
Aug 2 '10 #6
missinglinq
3,532 Expert 2GB
But apparently the afterupdate property is not working properly
The AfterUpdate event is working exactly as it is designed to work! As NeoPa has already said, a control's AfterUpdate() event only fires when the data in it has been entered physically, either by the user typing in the data or pasting it in from elsewhere. It does not fire when it is populated thru code, which is what you are doing here.

To get the AfterUpdate() to fire under these conditions you have to explicitly Call the sub.

Linq ;0)>
Aug 2 '10 #7
NeoPa
32,556 Expert Mod 16PB
This is getting somewhat frustrating. You keep coming up with things I've already provided answers to. The event you need is the Form_Current event. Of course the others won't work. I've already said that.
Aug 2 '10 #8

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

Similar topics

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...
2
by: c.kurutz | last post by:
Hello everyone. I have a problem with looking up pricing. Here is what I have so far: TABLES tblItems: itemid itemdescription itemunit (each, roll, square foot) location1price
4
by: Macbane | last post by:
Hi, I have a 'main' form called frmIssues which has a subform control (named linkIssuesDrug) containing the subform sfrmLink_Issues_Drugs. A control button on the main form opens a pop-up form...
13
by: bitsnbytes64 | last post by:
Hi, I have a form which contains a subform. Both are were creetd using the form wizard and are bound by the column IXO_NR (on two different tables), which is the control source for a textbox on...
7
by: dscarbor | last post by:
I have a simple form with 4 fields, and a subform that retrieves records that are potential matches based on a query. The user will use the ID from the subform record and enter it into one of the...
2
by: rlamber | last post by:
Hello, I have 2 subforms in a Main form, one links fine, the other doesn't. I am trying to link them both to a "tracking ID" on the main form. The Tracking ID is a text field that is a combination...
1
by: ckrows | last post by:
Hi guys, I have a parent form that displays the subform. The subform query has a link back to the original ID. I was having issues keepign them in sync, since every parent may not need a...
0
by: skips84s | last post by:
I have a parent form with four tabbed subforms. On subform x, selecting a value from a combo box should update a few controls on this subform, as well as a control on subform y, all done using...
5
by: hbaf208 | last post by:
I have a combobox on a subform that is based on an SQL that uses a listbox on the unbound parent form as the criteria. When the form is first loaded, it works perfectly, limiting the dropdowns to...
4
by: dgunner71 | last post by:
All, I have a Parent form where the Record Source is a query based on three tables (tblcustomers, tblEquipment, and tblWorkOrders). The Parent form has a subform based on a 4th table...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.