473,466 Members | 1,538 Online
Bytes | Software Development & Data Engineering Community
Create 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_CaseNbrs
'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("qry_ToyShop_CaseNbrs_Update")
Set qd2 = db.QueryDefs("qry_ToyShop_CaseNbrs_Update_Child")
'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_Household_Info].Form![int_caseNbr] =
DMin("int_caseNbr", "tbl_ToyShop_CaseNbrs",
"IsNull([tbl_ToyShop_CaseNbrs].[dte_assgnd])")
Me.[Applicant_Household_Info].Form![dte_giftsAppt] =
DMin("dte_appt", "tbl_ToyShop_CaseNbrs",
"IsNull([tbl_ToyShop_CaseNbrs].[dte_assgnd])")
Me.[Applicant_Household_Info].Form![dte_giftsTime] =
DMin("dte_Time", "tbl_ToyShop_CaseNbrs",
"IsNull([tbl_ToyShop_CaseNbrs].[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_Household_Info.
[Form]![int_caseNbr]
qd1.Execute
DoCmd.SetWarnings False ' turn off user prompts
DoCmd.OpenQuery "qry_ToyShop_CaseNbrs_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_CaseNbrs_Update_Child"
DoCmd.SetWarnings True ' turn off user prompts
'DoCmd.RunSQL "UPDATE tbl_Applicant_History INNER
JOIN (tbl_Child_History INNER JOIN tbl_Child ON
tbl_Child_History.ID_child = tbl_Child.ID_child) ON
tbl_Applicant_History.ID_app = tbl_Child.ID_app SET
tbl_Child_History.int_caseNbr = tbl_applicant_history.int_casenbr
WHERE (((tbl_Child_History.int_appYr)=Year(Date())) AND
((tbl_Child.ID_app)=[forms]![frm_applicant].[id_app]) AND
((tbl_Applicant_History.int_appYr)=Year(Date()))); "
'Print the Signature and Appointment Form
DoCmd.OpenReport "rpt_ToyShop_ApptSigForms"
Else
DoCmd.CancelEvent
End If
End Sub

Thanks for any help - Liz

Oct 21 '07 #1
0 2022

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

Similar topics

3
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...
13
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...
1
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...
5
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...
6
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...
2
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...
2
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...
4
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...
11
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...
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
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...
1
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...
0
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...
0
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...
0
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 ...

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.