Event for Form on a tab control: Force User to Click Save button

J

Jinjer

Hello!
I need some help with an Access 2003 application.

The application I am coding has the following:

- a main form with a tab control on which are forms and subforms
- one of the tabs has another form with a second tab control on which are
forms and subforms
- data from the input on one form is used to provide criteria for
selecting what data shows on the next form. The tabs are in the logical
order of the user's work process.
- After additions or changes, many of the variables are set and text
fields populated (as well as running some other code) when the SAVE button is
clicked.

I want to force the user to click the save button after adding or editing
data and not just move to the next tab. I was thinking of perhaps cancelling
the tab control's on change event and bringing up a dialog box that requests
them to save the record and setting the focus on the SAVE button.

Any suggestions as to which event property on the form or tab would best
achieve this and what the code could look like?

Thanks in advance,
 
M

Marshall Barton

Jinjer said:
Hello!
I need some help with an Access 2003 application.

The application I am coding has the following:

- a main form with a tab control on which are forms and subforms
- one of the tabs has another form with a second tab control on which are
forms and subforms
- data from the input on one form is used to provide criteria for
selecting what data shows on the next form. The tabs are in the logical
order of the user's work process.
- After additions or changes, many of the variables are set and text
fields populated (as well as running some other code) when the SAVE button is
clicked.

I want to force the user to click the save button after adding or editing
data and not just move to the next tab. I was thinking of perhaps cancelling
the tab control's on change event and bringing up a dialog box that requests
them to save the record and setting the focus on the SAVE button.

Any suggestions as to which event property on the form or tab would best
achieve this and what the code could look like?


How about disabling the tab pages and only enabling them in
the save button's Click event?
 
J

Jinjer

Hi, Marshall.

I don't think that would work. Not every task on the forms requires the
record to be saved. The user needs to be able to move from tab to tab, even
randomly if they want. I need it to force the save only when there has been
an add new or an edit, so that the variables are refreshed with the new
information.
 
M

Marshall Barton

Jinjer said:
I don't think that would work. Not every task on the forms requires the
record to be saved. The user needs to be able to move from tab to tab, even
randomly if they want. I need it to force the save only when there has been
an add new or an edit, so that the variables are refreshed with the new
information.


How do we tell if its an add new or edit?

Would the Dirty event be sufficient or would that be too
late? If you have a button or something that users click to
indicate they want to add or edit a record, that could be
the place to disable the tab pages and enable the save
button.
 
J

Jinjer

The DIRTY event doesn't seem to be available for a form on a tab control. I
keep getting error messages that the object doesn't support this method.
I've tried various ways such as:

Forms![ftc00Main]![CUSTOMER INFORMATION].Dirty in the On Change event
and
Me.Dirty in the form's Lost Focus event and On Exit event
as well as
code in the form's On Dirty event

None of these are working.

So, the question is how I get the tab control's On Change event to recognize
that the record on the form has not been saved.

Also, I don't really want to disable the tabs. I have to be a bit careful
here since this application will be used by managers and sales reps.

Thanks,
 
D

Douglas J. Steele

Exactly what do you mean by "a form on a tab control"? Are you talking that
you've got a subform on the page (in which case you need to look at the
Dirty property of the Form object in the subform control), or are you simply
talking about controls on the page that refer to the RecordSource of the
form (in which case you use the form's Dirty property)

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Jinjer said:
The DIRTY event doesn't seem to be available for a form on a tab control.
I
keep getting error messages that the object doesn't support this method.
I've tried various ways such as:

Forms![ftc00Main]![CUSTOMER INFORMATION].Dirty in the On Change event
and
Me.Dirty in the form's Lost Focus event and On Exit event
as well as
code in the form's On Dirty event

None of these are working.

So, the question is how I get the tab control's On Change event to
recognize
that the record on the form has not been saved.

Also, I don't really want to disable the tabs. I have to be a bit careful
here since this application will be used by managers and sales reps.

Thanks,
--
Jinjer


Marshall Barton said:
How do we tell if its an add new or edit?

Would the Dirty event be sufficient or would that be too
late? If you have a button or something that users click to
indicate they want to add or edit a record, that could be
the place to disable the tab pages and enable the save
button.
 
J

Jinjer

Hello, Doug.

I have a main form with a tab control; on each tab is a subform with it's
own fields, controls, and record source; there is even one tab that has a
subform with another tab control with subforms in the same type of setup.

In the last few minutes, I have figured out that by using the subform's On
Dirty event to set a global variable (which I call giDirty) to 1, the tab
control's On Change event can recognize that the edited record on the subform
has not been saved. I can do this for each subform so that if the user tries
to change tabs without saving, code can run.

My main challenge now is how to set the focus back to the tab with the dirty
form. Any suggestions?
--
Jinjer


Douglas J. Steele said:
Exactly what do you mean by "a form on a tab control"? Are you talking that
you've got a subform on the page (in which case you need to look at the
Dirty property of the Form object in the subform control), or are you simply
talking about controls on the page that refer to the RecordSource of the
form (in which case you use the form's Dirty property)

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Jinjer said:
The DIRTY event doesn't seem to be available for a form on a tab control.
I
keep getting error messages that the object doesn't support this method.
I've tried various ways such as:

Forms![ftc00Main]![CUSTOMER INFORMATION].Dirty in the On Change event
and
Me.Dirty in the form's Lost Focus event and On Exit event
as well as
code in the form's On Dirty event

None of these are working.

So, the question is how I get the tab control's On Change event to
recognize
that the record on the form has not been saved.

Also, I don't really want to disable the tabs. I have to be a bit careful
here since this application will be used by managers and sales reps.

Thanks,
--
Jinjer


Marshall Barton said:
Jinjer wrote:
I don't think that would work. Not every task on the forms requires the
record to be saved. The user needs to be able to move from tab to tab,
even
randomly if they want. I need it to force the save only when there has
been
an add new or an edit, so that the variables are refreshed with the new
information.


How do we tell if its an add new or edit?

Would the Dirty event be sufficient or would that be too
late? If you have a button or something that users click to
indicate they want to add or edit a record, that could be
the place to disable the tab pages and enable the save
button.
 
J

Jinjer

I finally, through trial and error, figured it out. In the On Change event
for the tab control, I used:

Forms![MainForm]![Tab Name].SetFocus

Whew! All is resolved!
--
Jinjer


Jinjer said:
Hello, Doug.

I have a main form with a tab control; on each tab is a subform with it's
own fields, controls, and record source; there is even one tab that has a
subform with another tab control with subforms in the same type of setup.

In the last few minutes, I have figured out that by using the subform's On
Dirty event to set a global variable (which I call giDirty) to 1, the tab
control's On Change event can recognize that the edited record on the subform
has not been saved. I can do this for each subform so that if the user tries
to change tabs without saving, code can run.

My main challenge now is how to set the focus back to the tab with the dirty
form. Any suggestions?
--
Jinjer


Douglas J. Steele said:
Exactly what do you mean by "a form on a tab control"? Are you talking that
you've got a subform on the page (in which case you need to look at the
Dirty property of the Form object in the subform control), or are you simply
talking about controls on the page that refer to the RecordSource of the
form (in which case you use the form's Dirty property)

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Jinjer said:
The DIRTY event doesn't seem to be available for a form on a tab control.
I
keep getting error messages that the object doesn't support this method.
I've tried various ways such as:

Forms![ftc00Main]![CUSTOMER INFORMATION].Dirty in the On Change event
and
Me.Dirty in the form's Lost Focus event and On Exit event
as well as
code in the form's On Dirty event

None of these are working.

So, the question is how I get the tab control's On Change event to
recognize
that the record on the form has not been saved.

Also, I don't really want to disable the tabs. I have to be a bit careful
here since this application will be used by managers and sales reps.

Thanks,
--
Jinjer


:

Jinjer wrote:
I don't think that would work. Not every task on the forms requires the
record to be saved. The user needs to be able to move from tab to tab,
even
randomly if they want. I need it to force the save only when there has
been
an add new or an edit, so that the variables are refreshed with the new
information.


How do we tell if its an add new or edit?

Would the Dirty event be sufficient or would that be too
late? If you have a button or something that users click to
indicate they want to add or edit a record, that could be
the place to disable the tab pages and enable the save
button.
 

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

Top