I've been beating my head against this problem for the last several
days, and I haven't found a decent solution yet. So I'm turning to the
group for some moral support or better yet some answers.
Background:
I want the user to be able to close the form by using the "x" button
in the window title bar, I do not want to disable this. I have found a
nice solution in the Access Developer's Handbook that disables the
"x", however I am hoping to avoid using this solution since I like
having the "x" available to the user.
The form that needs the Controlled Close has a subform in datasheet
view; the subform is linked to the main form using the primary /
foreign key.
My question:
Under this scenario, has anybody made the controlled close to work? If
so, what is the general coding strategy?
I've gone through several iterations of code, here is a mock up of
where I've ended; btw it doesn't work very well, several errors result
in akward form handling.
Form_Load
'Nothing here related to controlled close
Form_Current
'Nothing here either
Form_BeforeUpda te
'Check for empty form
'If empty, exit sub
'Validate form
'If invalid Cancel = True, Exit Sub
Form_Unload
'Call Form_BeforeUpda te
'If invalid form then Cancel = True
'Repopulate form with user input
'Exit Sub
Function ValidateForm
'Check for empty form
'Various error checking
'Check for empty subform (note: user cannot access subform until all
required fields in
'parent form are completed
'Various error checking
'If invalid, returns False and sets mod variable strError to text
describing error
Form_Error
'If incomplete form error (2169) then
'Msgbox allow user to Save ('yes'), Not Save ('no'), or Cancel close
('cancel')
'If user wants to continue editing current record, then
'Prompt user with error msg from mod variable strError
'And set variables up to repopulate form with user input in Form_Unload
days, and I haven't found a decent solution yet. So I'm turning to the
group for some moral support or better yet some answers.
Background:
I want the user to be able to close the form by using the "x" button
in the window title bar, I do not want to disable this. I have found a
nice solution in the Access Developer's Handbook that disables the
"x", however I am hoping to avoid using this solution since I like
having the "x" available to the user.
The form that needs the Controlled Close has a subform in datasheet
view; the subform is linked to the main form using the primary /
foreign key.
My question:
Under this scenario, has anybody made the controlled close to work? If
so, what is the general coding strategy?
I've gone through several iterations of code, here is a mock up of
where I've ended; btw it doesn't work very well, several errors result
in akward form handling.
Form_Load
'Nothing here related to controlled close
Form_Current
'Nothing here either
Form_BeforeUpda te
'Check for empty form
'If empty, exit sub
'Validate form
'If invalid Cancel = True, Exit Sub
Form_Unload
'Call Form_BeforeUpda te
'If invalid form then Cancel = True
'Repopulate form with user input
'Exit Sub
Function ValidateForm
'Check for empty form
'Various error checking
'Check for empty subform (note: user cannot access subform until all
required fields in
'parent form are completed
'Various error checking
'If invalid, returns False and sets mod variable strError to text
describing error
Form_Error
'If incomplete form error (2169) then
'Msgbox allow user to Save ('yes'), Not Save ('no'), or Cancel close
('cancel')
'If user wants to continue editing current record, then
'Prompt user with error msg from mod variable strError
'And set variables up to repopulate form with user input in Form_Unload
Comment