My Assistant
![]() ![]() |
|
|
Apr 7 2009, 03:48 PM
Post
#1
|
|
|
UtterAccess Addict Posts: 149 |
hi, i created a main form frmExam and a subform frmGrade.
in the code below... if tf is False frmGrade recordsource changes from tblGrade to tblGradeCopy ( a local copy of tblGrade) i added this code to insert new records in tblGradeCopy: docmd.RunSQL ("insert into tblGradeCopy (fldExamId) values(4)") ...however the subform does not show these added records. Any ideas why? please help, thank you so much! CODE Function ExamRecordSource(tf As Boolean)
Select Case tf Case True With Form_frmExam .RecordSource = "tblExam" .RecordSelectors = False .cntClass.ControlSource = "fldClassId" .cntSection.ControlSource = "fldSectionId" .cntClass.RowSource = "select fldClassId,fldClass from tblClass" .cntSection.RowSource = "select fldSectionId,fldSection from tblSection" .AllowAdditions = False End With With Form_frmGrade .RecordSource = "tblGrade" .cntExamId.ControlSource = "fldExamId" .cntStudentId.ControlSource = "fldStudentId" .AllowEdits = False End With Case False With Form_frmExam .RecordSource = "" .RecordSelectors = False .cntClass.ControlSource = "" .cntSection.ControlSource = "" .cntClass.RowSource = "select fldClassId,fldClass from tblClass" .cntSection.RowSource = "select fldSectionId,fldSection from tblSection" .cntClass = "" .cntSection = "" .AllowEdits = True End With With Form_frmExam.frmGrade DoCmd.RunSQL ("delete from tblGradeCopy") docmd.RunSQL ("insert into tblGradeCopy (fldExamId) values(4)") .Form.RecordSource = "tblGradeCopy" .Controls("cntExamId").ControlSource = "fldExamId" .Controls("cntStudentId").ControlSource = "fldStudentId" .Form.AllowAdditions = True .Form.DataEntry = False .Requery End With End Select End Function |
|
|
|
Apr 7 2009, 07:04 PM
Post
#2
|
|
|
UtterAccess VIP Posts: 569 From: North Augusta, SC |
Is fldExamID the link field between tblGradeCopy and table on which the parent form is based? If so, have you properly set your Master/Child links on the subform control to reflect this?
Is "frmExam" the Parent form? If so, you're setting the Recordsource of that form to nothing ... if you have set the Master/Child links properly, then this would, of course, show no records (since the Parent record would be nothing, the Child records would also be nothing). Try setting the RecordSource of frmExam to something (perhaps the same as if your SElect Case is True) and see if the records show up. |
|
|
|
Apr 8 2009, 11:11 AM
Post
#3
|
|
|
UtterAccess Addict Posts: 149 |
Thank you Scott for your reply.
fldExamID is NOT the link between tblGradeCopy and tblExam. It is the link between tblGrade and tblExam. frmExam is the parent form, frmGrade is the subform. I'm only using tblGradeCopy [local copy of tblGrade] to add new exmas. That is why i set frmGrade recordsource to tblGradeCopy then switch the recordsource back to tblGrade. In my BE, i've created a relationship between tblExam and tblGrade [linked field fldExamId]. i set the frmGrade recordsource to tblGradeCopy also for the same reason of adding an exam and setting the grades for all students in this Class/Section. [ moving the data from tblGradeCopy to tblGrade is simple, whatever in frmExam goes to tblExam. whatever is in tblGradeCopy goes to tblGrade having same fldExamId as the Exam Id in frmExam] Edited by: ALMU3YN on Wed Apr 8 12:12:04 EDT 2009. Edited by: ALMU3YN on Wed Apr 8 12:15:11 EDT 2009. |
|
|
|
Apr 10 2009, 11:38 AM
Post
#4
|
|
|
UtterAccess Addict Posts: 149 |
I created a relationship between a local tblExamCopy and tblGradeCopy.
i then set frmExam recordsource=tblExamCopy and frmGrade recordsource=tblGradeCopy In order to save i use two runSQL commands. One puts tblExamCopy in tblExam and the other tblGradeCopy in tblGrade. |
|
|
|
![]() ![]() |
|
Go to Top · Lo-Fi Version | Time is now: 19th May 2013 - 08:43 PM |