Reference Errors Problem

E

EarlCPhillips

I am a volunteer programmer at the local Food Bank. I manage the volunteer
tracking program. Lately I have noted that some records end up with
incorrect values in spite of thorough data editing during input (dates,
codes, etc.). I force a recheck of data whenever a transfer to a new record
occurs, stopping the transfer if editing is not correct. This seems to work
well. It calls the Form_BeforeUpdate prior to the transfer. I set a global
variable to true if editing is in error so I have a switch to check before
transfer.

Still, some records get saved with obvious errors in the data, e.g. a date of
3009, an invalid activity code. I tried testing before closing by calling the
original edit event (Form_BeforeUpdate) from the shutdown event (Form_Close)
to try to verify that all edits are still correct. I encounter reference
errors when the event Form_BeforeUpdate is called from the Form_Close, in
spite
of using explicit references, such as
"If IsNull(Forms!frmMain!Scheduling!ScheduleDate) Then" or
"If IsNull(Forms("frmMain")("Scheduling")("ScheduleDate")) Then"

where the main form "frmMain" contains control "Scheduling", which contains
sub-form frmActivity, which contains field ScheduleDate, the scheduled date of
the proposed activity. These references work fine as long as I check the data
from a combo box used to transfer to another record. However, when I call
this same subroutine from the MS Access Class Object frmMain Form_Close
event, it fails with a bad reference.

Why the reference errors?
 
D

Douglas J. Steele

The correct way to refer to control "ScheduleDate" which is on sub-form
"frmActivity", which is contained in control "Scheduling" on form "frmMain"
is Forms!frmMain!Scheduling.Form!ScheduleDate

See http://www.mvps.org/access/forms/frm0031.htm at "The Access Web" for a
good reference to referring to form and subform properties and controls.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Close a Form 2
Add 4
Form Load problem 2
Forms 3
Newbie data validation question 1
Compile error: label not defined 5
How to search for a frmMain by searching idSub on frmSubForm ?? 1
Form_beforeUpdate question 5

Top