By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,836 Members | 2,059 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,836 IT Pros & Developers. It's quick & easy.

Child Record Not Updating through code

P: n/a
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
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.