473,714 Members | 2,111 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Child Record Not Updating through code

Hello and TIA for any help with this non profit Christmas assistance
project.

I have an applicant (app history) and child (child history) tables (4
total). I need to grab the next available (in house case number, appt
date and time) for the applicants yearly history and the childs yearly
history and then print a report with the applicants info and this in
house case number. The forms are linked with ID_app (from the
applicant table).

I can grab the number using DMIN and update my case number table, it
populates the applicant table but I run into problems with the child
history and the report. On the first try, the child history record
case number is blank, if I run the code again, then applicant history
record increments but the child history record is getting the previous
case number. The forms are a main form with a tab control. The first
page has a subform within a subform (child and child yearly history).
The second page has a subform (applicant yearly history). The report
is also falling into the same trap as the child history.

I enter some data into the child history form, then go to the
applicant history form. This is where the code starts from, grad the
case nbr, update the case nbr table, update the child record(s) print
the report.

Here is the code I am using - I tried both the query def and pure SQL,
neither works in the code. But the query works if I run it with the
form open, the child record get the correct case number and the report
prints the right info.

Private Sub cmdAssgnCaseNbr _Click()
'assign case number - use next avail from tbl_ToyShop_Cas eNbrs
'update eligible child records with the same case number
'print the appointment and signature forms

Dim response
Dim result_YesNO
Dim db As Database
Dim qd1 As QueryDef
Dim qd2 As QueryDef
Dim rst As Recordset
Set db = CurrentDb
Set qd1 = db.QueryDefs("q ry_ToyShop_Case Nbrs_Update")
Set qd2 = db.QueryDefs("q ry_ToyShop_Case Nbrs_Update_Chi ld")
'Message box check Data Entry if all okay continue
If caseNbr_assign( result_YesNO) = vbYes Then
'Assign the case nbr and save the applicant record
Me.[Applicant_House hold_Info].Form![int_caseNbr] =
DMin("int_caseN br", "tbl_ToyShop_Ca seNbrs",
"IsNull([tbl_ToyShop_Cas eNbrs].[dte_assgnd])")
Me.[Applicant_House hold_Info].Form![dte_giftsAppt] =
DMin("dte_appt" , "tbl_ToyShop_Ca seNbrs",
"IsNull([tbl_ToyShop_Cas eNbrs].[dte_assgnd])")
Me.[Applicant_House hold_Info].Form![dte_giftsTime] =
DMin("dte_Time" , "tbl_ToyShop_Ca seNbrs",
"IsNull([tbl_ToyShop_Cas eNbrs].[dte_assgnd])")
Me.ynShareInfo. Value = True
DoCmd.Save
'Run the update query to take the case number out of the
pool
qd1.Parameters( "[forms]![frm_applicant]![Applicant
Household Info].[form]![int_caseNbr]") = Me.Applicant_Ho usehold_Info.
[Form]![int_caseNbr]
qd1.Execute
DoCmd.SetWarnin gs False ' turn off user prompts
DoCmd.OpenQuery "qry_ToyShop_Ca seNbrs_Update"
'Run the update query to assign the case number to
the child's record
qd2.Parameters( "[forms]![frm_applicant].[id_app]")
= Me.ID_app
qd2.Execute
DoCmd.OpenQuery
"qry_ToyShop_Ca seNbrs_Update_C hild"
DoCmd.SetWarnin gs True ' turn off user prompts
'DoCmd.RunSQL "UPDATE tbl_Applicant_H istory INNER
JOIN (tbl_Child_Hist ory INNER JOIN tbl_Child ON
tbl_Child_Histo ry.ID_child = tbl_Child.ID_ch ild) ON
tbl_Applicant_H istory.ID_app = tbl_Child.ID_ap p SET
tbl_Child_Histo ry.int_caseNbr = tbl_applicant_h istory.int_case nbr
WHERE (((tbl_Child_Hi story.int_appYr )=Year(Date())) AND
((tbl_Child.ID_ app)=[forms]![frm_applicant].[id_app]) AND
((tbl_Applicant _History.int_ap pYr)=Year(Date( ))));"
'Print the Signature and Appointment Form
DoCmd.OpenRepor t "rpt_ToyShop_Ap ptSigForms"
Else
DoCmd.CancelEve nt
End If
End Sub

Thanks for any help - Liz

Oct 21 '07 #1
0 2040

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
3463
by: vishnu mahendra | last post by:
I have two table both say A and B. If i insert a record in A that record should be inserted in B. If i delete a record in A that record should be deleted from B. Is that possible.If yes please tell me. Thankyou in advance, vishnu
13
7408
by: Stuart McGraw | last post by:
I haven't been able to figure this out and would appreciate some help... I have two tables, both with autonumber primary keys, and linked in a conventional master-child relationship. I've created forms for both those tables, and inserted the child table form into the master table form as a subform. It works just as it is supposed to, in that I can create a new master record, and then add detail records.
1
1046
by: pete matthews | last post by:
HI. I have a dataset with two tables. Table 1 is parent and table 2 is child. Am populating a single datagrid with records from child table derived from a single parent record. I am then allowing users to edit child records in datagrid. Users have an update option for each row in the datagrid. How do I then write the updated child record from the datagrid to the dataset ??? The user presses an update button which fires the itemcommand. I...
5
3539
by: PAUL | last post by:
Hello, I have 2 tables with a relationship set up in the dataset with vb ..net. I add a new record to the parent table then edit an existing child record to have the new parent ID. However when I do the update the changed parentid in the child table fails to change. No error is given its just that the change is not written to the Database. When I step through the records for the child table the one I would expect to be changed has a row...
6
1714
by: Kevin | last post by:
I've got an mdiParent form. I open an instance of a child form like this: Dim frmChild as New frmCustomers frmChild.Show() I've got a few of these open at a time. On each frmChild I open another form that displays customer data. When I make changes and save the customer data, I need the updated data to show on the correct frmChild. How do I know which form opened the customer data form and
2
3465
by: Swinky | last post by:
I hope someone can help...I feel like I'm walking in the dark without a flashlight (I'm NOT a programmer but have been called to task to do some work in Access that is above my head). I have code that will successfully copy a record and append the information to a new record in the same table (parent table) within a form. However, there are related child tables with primary keys (set to Autonumber) stored in sub-forms. That information...
2
4422
by: =?Utf-8?B?a2VubmV0aG1Abm9zcGFtLm5vc3BhbQ==?= | last post by:
vs2005, c# Trying to understand why one way works but the other doesnt. I have not tried to create a simpler mdi/child/showdialog app for posting purposes (I think even this would not be so small or simple). I am hoping the description will generate some ideas I can check out. PROBLEM: ----------------- Switching to UI thread using Invoke(), everything seems good.
4
6057
by: Harlequin | last post by:
I have a question concerning the need to trigger events within a "child" subform which is itself enbedded within a master "parent" form and which is accessible via a tab in the parent form. Becuase this is all very difficult to explain in words, please bear with me as I endevour to explain what it is I am trying to do. It would be helpful if I could attach a graphics file to this posting that would help explain what it is I'm trying to achieve...
11
4052
by: OldBirdman | last post by:
I have a form with several bound textboxes. These are routinely updated by User. The table in RecordSource for this form currently has 8 fields not shown on this form, but which occasionally need to be changed by User. For this I have created an "Advanced" commandbutton, which opens a child form with controls to display the remaining fields. I tried using recordsetclone to put the child form on the same record and recordset as the main...
0
8713
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9318
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9187
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
6638
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5961
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4467
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4730
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3164
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2529
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.