Working with Tabbed forms

abette

Member
Local time
Today, 13:44
Joined
Feb 27, 2021
Messages
85
Hi - I have a tabbed form in an Access database I am designing for process claims. Each tab represents a different fund type. My main table will contain the individual claims. I also have a table that contains just the funding type names. Each tab contains an identical form with all the same exact controls (control source is my claims table). Each has a fund type combo control that is bound to the funding type names table (like a lookup). I would like the funding type control for each tab to default to the fund type (which is the name of the tab). I thought I could do this by setting the default value for each control on the tab to the respective fund type (again is the same as the tab name) but when I do they all default to 1 tab name. Note, I created a tabbed form style for inputting records and than another separate tabbed form for updating. All videos I have seen regarding tabbed style forms show them being used as sub forms linked to the main or first sheet tab. That isn't quite what I want. I would like each to operate independently as their own form based on the funding type. Is this feasible or am I dreaming?!
Here's a sample of my form:

1621529937809.png
 
That isn't quite what I want. I would like each to operate independently as their own form based on the funding type. Is this feasible or am I dreaming
You can certainly do that, and it kind of looks like you already have (?)

Just create a tab control, add a Page, and drag a Form object from the left-hand pane, onto that particular tab page. Independent form is creating, operating with no dependencies on anything else.

Set the recordsource of the form however you want
 
i only use 1 subform
this prevents memory problems of using 1 subform for each tab.
then when user clicks a tab, swap out the source of the subform

Code:
Select Case TabCtl4.Value
  Case "Phones"
     subFrm.SourceObject = "frmPhones"
  Case "clients"
     subFrm.SourceObject = "frmClients"
  Case "Invoices"
     subFrm.SourceObject = "frmInvoices"
End Select
 
Hi Ranman256 - FYI I am not doing this via VBA code. I am manually using Access features and form commands.
Isaac - I can't seem to get each tab to operate as it's own form. I tried saving each funding type as its own form and them pulling them in as sub forms but it doesn't seem to work. Ugh.
 
There is sometimes a conflict between "your" way and the Access way. I've been working with Access for 25+ years and I can tell you from experience that you are always better off doing things the Access way. For the 25 years before Access, I did things the COBOL way and have the scars from that experience also:)

As I look at your form it occurs to me that you have a "spreadsheet" vision of the world rather than a relational database vision and that is what is contributing to your problems. Tabs are like "fields" and you have what we call a repeating group. Would you ever create a form to collect employee data and create tabs named Mary, Joe, Sally? The obvious reason not to is that a different employee might have 12 children with different names so you could never get the tabs to work unless you named them Child1, Child2, etc. (this is essentially what you are doing and exactly why you are having trouble making Child1 be Mary. How about if you were automating a bank? Would you have each site on a separate tab? making tabs for each claim type is very similar.

A better solution would be to use a main form with all common data and a subform with the unique data for any given claim type. This minimizes your coding efforts since there is only one validation procedure for the common data. Then hopefully, you won't have too many subforms to handle the unique data. The main form would have a combo to select claim type and once the record is saved, the cboClaimTypeID would be locked to prevent future changes. If you pick the wrong claim type and go as far as saving the record, you would need to delete the record and start again OR, your code could check to see if any child record has been created and if not, you could allow the value of the combo to be changed.

Once the record is saved, the correct subform would be loaded (this would also happen in the form's current event so you could scroll through records).

If you are not creating separate tables for each claim type (there are pros and cons), then rather than using subforms, you could use a tab control without any visible tabs and just add code to show the tab you want to see. That allows all the controls to be on the same form but not visible in all cases.

And finally, using separate forms for data entry and data update also causes unnecessary duplication of effort and will lead to data anomalies as you change the edit rules on the add form but forget to change them on the update form. Don't do it.
 

Users who are viewing this thread

Back
Top Bottom