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

Update a field in form from a subform

Hi Guys,

Wonder if anyone could help me out.

I've got a form [FrmQuoteHeader] with a record source link to [TblQuoteHeader]. The form has a subform embedded. The link between the two is a job number [QuoteNumber]. I am trying (and failing) to update a 'Yes/No' [ShowInJobs] field on the form/table when a 'Yes/No' [Job] field is updated in the subform.

So, basically, when any one of the subform records has the field [Job] set to YES, it updates the [ShowInJobs] field in the table [TblQuoteHeader].

Hope that makes sense!?! :-S

Any help would be great.
Jan 25 '08 #1
3 1732
FishVal
2,653 Expert 2GB
Hello, Andy.

I suggest you the following:
  • modify [FrmQuoteHeader].RowSource so it will return field which will be True when any record in subform's linked table (lets call it [tbl]) has [Job] field set to True
    Expand|Select|Wrap|Line Numbers
    1. SELECT [TblQuoteHeader].*, -Sgn(DCount("*","tbl","[QuoteNumber]=" & [TblQuoteHeader].[QuoteNumber] & " AND [Job]=True")) AS blnShowInJobs
    2. FROM [TblQuoteHeader];
    3.  
    * using DLookUp instead of DCount supposed to be more effective as it prevent the whole table scanning
    Expand|Select|Wrap|Line Numbers
    1. ... -Sgn(Nz(DCount("[QuoteNumber]","tbl","[QuoteNumber]=" & [TblQuoteHeader].[QuoteNumber] & " AND [Job]=True"),0)) AS blnShowInJobs
    2.  
  • set [ShowInJobs].ControlSource property to blnShowInJobs
  • for the subform [Job] control write the following AfterUpdate event handler
    Expand|Select|Wrap|Line Numbers
    1. Private Sub bln_Job()
    2.     Me.Parent.Refresh
    3. End Sub
    4.  

Regards,
Fish
Jan 25 '08 #2
Hi Fish,

Thanks for the reply.

Just a question, when you say update the RowSource in your first point, do you mean the RecordSource? or am I not understanding something?

I'm just trying to understand the whole thing rather than just 'copy' 'paste'.



Thanks,

Andy.
Jan 28 '08 #3
FishVal
2,653 Expert 2GB
Sure, RecordSource.
Jan 28 '08 #4

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

Similar topics

1
by: Kunal | last post by:
Hi, I need some help on writing an update query to update "UnitsSold" field in Products Table whenever I save a transaction. The transaction may contain several "Subtransactions", one for each...
2
by: Rosy | last post by:
I have a sub-form(company name & address) that is connected to my contact listing. When I change the contact, it doesn't update the subform until I close the main form or refresh. Is there a way...
9
by: DP | last post by:
hi., i've got 3 tables, customer, film and filmrental. i've got a customer form, with a sub form at the bottom, which is a film rental subform. i've created an update query, which when a...
1
by: jburris | last post by:
I am completely new to VBA. I am trying to update a yes/no box in a subform based on a value that I call from the main form into the subform. Below is the if /then statement i am using: If...
1
by: jeffro | last post by:
I have a database used for recording survey data. In the database, I have a form that displays a survey participant and a subform that is filled in by selecting a question from a looklist and...
0
by: Access Programming only with macros, no code | last post by:
ERROR MESSAGE: Could not update; currently locked by another session on this machine. BACKGROUND I have the following objects: Table1 - HO (which has about 51,000+ records) Table2 -...
6
by: KevinPreston | last post by:
Hello everyone, this is my first post so apologies if i dont get it right first time, i am a self taught Access user, i am stuck on something i am trying to do, briefly i have 2 tables, one for...
1
by: sconard | last post by:
When you create a form based on a table via access 2007 wizard, form will update when moving from field that has changed to another field within form. Each loss of focus in "changed" fields causes...
1
by: Rosie | last post by:
I have a main form with header info w/ 'tHeader' as the control source. I have a subform with 'tDetail' as a control source. They're strung together by a field named MA_ID. This works...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
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
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.