Setting Subform Recordsource in a tabbed form

R

Rajesh B. Patel

Hi,

I have a form with one tab control. The tab control has 7 tabs. Each tab in
turn has 5 or more subforms in it. I am having a problem switching between
tabs after using the database splitter to separate my application for
multi-user environments. The problem is I get "Runtime Error: 3048 Cannot
open any more databases."

After doing a bit of research on the multiuser newsgroup I think that
problem is that since I set the Recordsource property on my subforms and
never unset it I am exceeding the allowable number of table ids.

As a possible fix I want to try setting the Recordsource of the subforms
that are no longer used to "Nothing". This must be doen when the user
switches tabs. How can I find out what tab I used to be on? I know I can
find out what tab I am currently on with Me.TabControl.Value, but I need
which tab I used to be on.

I need this because most my subforms all use the same underlying form and I
set the RecordSource dynamically in the TabControl's Change event. I
determine what data to populate into which subforms (the subforms are named
based on their tab number so a little routine just determines what the
appropriate names are for the subforms that are on the current tab and sets
their RecordSource property to a query that is specific to that tab number)
based on what tab I am on. So when the user switches tabs I need to wipe out
the RecordSource on the old subforms and setup the new RecordSource on the
current subforms.

I hope this makes sense.

I guess alternatively I could wipe out all subforms on every single
TabControl Change event a repopulate only the appropriate one. Do people out
there recommend I do this?

Thanks. Please let me know if I am unclear (I am sure I am...)

Thanks.
 
D

Dirk Goldgar

Rajesh B. Patel said:
Hi,

I have a form with one tab control. The tab control has 7 tabs. Each
tab in turn has 5 or more subforms in it. I am having a problem
switching between tabs after using the database splitter to separate
my application for multi-user environments. The problem is I get
"Runtime Error: 3048 Cannot open any more databases."

After doing a bit of research on the multiuser newsgroup I think that
problem is that since I set the Recordsource property on my subforms
and never unset it I am exceeding the allowable number of table ids.

As a possible fix I want to try setting the Recordsource of the
subforms that are no longer used to "Nothing". This must be doen when
the user switches tabs. How can I find out what tab I used to be on?
I know I can find out what tab I am currently on with
Me.TabControl.Value, but I need which tab I used to be on.

I need this because most my subforms all use the same underlying form
and I set the RecordSource dynamically in the TabControl's Change
event. I determine what data to populate into which subforms (the
subforms are named based on their tab number so a little routine just
determines what the appropriate names are for the subforms that are
on the current tab and sets their RecordSource property to a query
that is specific to that tab number) based on what tab I am on. So
when the user switches tabs I need to wipe out the RecordSource on
the old subforms and setup the new RecordSource on the current
subforms.

I hope this makes sense.

I guess alternatively I could wipe out all subforms on every single
TabControl Change event a repopulate only the appropriate one. Do
people out there recommend I do this?

That last is what I usually do. However, if you want you can have a
module-level variable in which you store the "current" value of the tab
control. You'd set it in the control's Change event, *after* using it
to identify what tab you used to be on.

Are *all* your subform's on this tab control displaying the same form?
If so, you could conceivably have just one subform control and put it,
not on any of the tab pages, but on top of the tab control, so that it
always shows no matter what tab you're on. Then you could just
manipulate this one subform's properties as you change from tab to tab.
 
R

Raj Patel

Dirk Goldgar said:
That last is what I usually do. However, if you want you can have a
module-level variable in which you store the "current" value of the tab
control. You'd set it in the control's Change event, *after* using it
to identify what tab you used to be on.

Are *all* your subform's on this tab control displaying the same form?
If so, you could conceivably have just one subform control and put it,
not on any of the tab pages, but on top of the tab control, so that it
always shows no matter what tab you're on. Then you could just
manipulate this one subform's properties as you change from tab to tab.

Hi Dirk,

For some reason I missed your mesage on my news client. Thanks for the
reply!

Unfortunately each tab has additional forms and they are ordered
differently so I cannot use your suggestion.

I tried implementing what I spoke of at the end of my post today.
Unfortunately I get the same "Cannot open any more databases" error. I
am setting the Recordsource = "" for all the unused subforms. Is this
the correct way to free up the table ids?

Thanks.

raj
 
D

Dirk Goldgar

Raj Patel said:
Hi Dirk,

For some reason I missed your mesage on my news client. Thanks for the
reply!

Unfortunately each tab has additional forms and they are ordered
differently so I cannot use your suggestion.

I tried implementing what I spoke of at the end of my post today.
Unfortunately I get the same "Cannot open any more databases" error. I
am setting the Recordsource = "" for all the unused subforms. Is this
the correct way to free up the table ids?

Are you sure your code is running the way you intend, to clear all the
the recordsources you're not using? When I've done this, it was the
SourceObject properties of the subform controls that I cleared, but I
don't know if that will make a difference or not. Still, in addition to
recordsources on the subforms, you may have rowsources for combo and
list boxes, so maybe clearing each unused subform control's SourceObject
property will be more effective.
 

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