472,143 Members | 1,586 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

Child Record Not Updating through code

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

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",
Me.[Applicant_Household_Info].Form![dte_giftsAppt] =
DMin("dte_appt", "tbl_ToyShop_CaseNbrs",
Me.[Applicant_Household_Info].Form![dte_giftsTime] =
DMin("dte_Time", "tbl_ToyShop_CaseNbrs",
Me.ynShareInfo.Value = True
'Run the update query to take the case number out of the
Household Info].[form]![int_caseNbr]") = Me.Applicant_Household_Info.
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
= Me.ID_app
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"
End If
End Sub

Thanks for any help - Liz

Oct 21 '07 #1
0 1914

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by PAUL | last post: by
2 posts views Thread by =?Utf-8?B?a2VubmV0aG1Abm9zcGFtLm5vc3BhbQ==?= | last post: by
reply views Thread by leo001 | last post: by

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.