Adding controls to a Tab control

  • Thread starter Thread starter Lee
  • Start date Start date
L

Lee

I posted this question earlier and didn't get a reply so I
thought I'd reword it.
What is the correct way to add bound controls to a tab
control? I need controls from 1 table split between 2
tabs. All controls were on the main form so I cut and
pasted the main form controls on the two tabs where
appropriate. When I do a refresh on the main form, if the
controls on the 2nd tab were edited, Access crashes.
Shouldn't Access be able to handle this? If I just move
to another record the update works ok without crashing.
I'm desparate for a workaround! If anyone can help me
with this, I sure would appreciate it.
Thanks!
 
Lee said:
I posted this question earlier and didn't get a reply so I
thought I'd reword it.
What is the correct way to add bound controls to a tab
control? I need controls from 1 table split between 2
tabs. All controls were on the main form so I cut and
pasted the main form controls on the two tabs where
appropriate. When I do a refresh on the main form, if the
controls on the 2nd tab were edited, Access crashes.
Shouldn't Access be able to handle this? If I just move
to another record the update works ok without crashing.
I'm desparate for a workaround! If anyone can help me
with this, I sure would appreciate it.
Thanks!

Your terminology is confusing me. You're referring to a "main form". Does this mean
you also have a subform?

In general, to distribute the controls of an existing form over Tab Pages, you just
add the TabControl and add as many pages to it as you need, and then Cut n' Paste the
existing controls onto the Tab Pages. This does not create a main form / sub form
situation. You still have just your one plain form that just happens to have its
controls distributed on Tab Pages.

The TabControl is nothing more that an organizational layout tool. It should not
change how your form works in any respect other than the Tab Order will behave a bit
differently. Your form does not care what page any bound control is on or if it is
not on any of the tab pages at all.
 
Lee said:
Rick,
You helped me last week.
Originally these controls were on the Main form. There
are several Tabs with Subforms with other controls. The
users wanted to split some of the controls on the Main
form onto another Tab. Because the controls were directly
on the main form, I had to move All of the main form
controls to two different tabs to keep the main form
controls from showing on the tab that didn't host a
subform. All is working now except when the "Save" button
is clicked and does a Mainform.refresh. If any of the
main form controls on the 2nd tab are edited, Access
crashes. If I move these controls on the 2nd mainform tab
to 1st tab all works ok.
I hope I explained this clear enough.

Well I don't understand that unless the form is corrupted. There should be no
difference between a control being on one tab page versus another. Is the only
command in your "Save" button a refresh? What is the exact syntax?
 
Rick, I think the form is corrupt. I just created a new
database and imported the form (and all other stuff to
make it work) and it updates without crashing!

To answer your question, the Refresh command is:

Forms!FrmMain.Form.Refresh

This is actually called from another form with several
options. One option is the above .refresh command.
 
Lee said:
BTW - What's the best way to recover a corrupt form?
I'm a VB programmer and this is my first Access
application of any size.

Sometimes the undocumented SaveAsText and LoadFromText functions will fix a messed up
form. I have had occasions though where reverting to the most recent backup was the
only way so you need to make those frequently.
 
Rick,
Now I don't think it's the form. I just Imported the
original form from the production .mdb (without the
changes), Added the new tab, cut the controls from the
main form and pasted them to the tab pages, I copied all
the new form code (from my renamed form). It still
crashes when editing a control on the 2nd Tab.
 
Lee said:
Rick,
Now I don't think it's the form. I just Imported the
original form from the production .mdb (without the
changes), Added the new tab, cut the controls from the
main form and pasted them to the tab pages, I copied all
the new form code (from my renamed form). It still
crashes when editing a control on the 2nd Tab.

Perhaps the production copy was already messed up?

I would start fresh with a brand new form. Build it right from the get-go with a
TabControl on it and place the controls directly on the TabPages as you add them. Do
not add any subforms at first. Just the controls for the main form and the
TabControl and see if the problem still occurs.
 
I've found the source of the problem.
The Main Form's .Refresh was causing the Form_Current
event which subsequently caused all the subform's _Current
event to fire. There was code in some of these that
called a module procedure that does some set up actions
for these forms. It appears that the conditional
formatting on some of these controls is what's cauing the
crashing. I've noticed that after initially moving the
Main Form's controls to the tab pages that I had problems
with conditional formatting on these controls and I
removed it. I don't know why the conditional formatting
is giving me problems now and it was working before the
controls were moved but I'll just work around it. Thanks
again for your help Rick!
 
Back
Top