Subform on TabControl (1 Viewer)

JPR

Registered User.
Local time
Yesterday, 16:12
Joined
Jan 23, 2009
Messages
192
Hello,
I am designing a simple db and have created a main form (frmMenu) with a tab control with three pages. On each page, I have placed a different subform.

On page1, I have Subform1. This form gets its records from Table1 and has an unbound combo box that allows to move directly to the selected record.
What I would like to do is to open Page1 and view the SubForm1 blank without data. Users should select the record to view the entire recordset.

I would also like users to be able to modify or add data to this form but do not know what vba code to write down.
Can anyone help out with this? Appreciate your help.
 

Micron

AWF VIP
Local time
Yesterday, 19:12
Joined
Oct 20, 2018
Messages
3,478
Users should select the record to view the entire recordset.
Does that mean choose a combo box list item? Kind of hard to select a record on a form if there are none showing? Maybe what you need to do is apply a filter on subform load that causes no records to display, then modify the filter upon combo AfterUpdate event. Or use that event to set the subform recordsource property from nothing (in design view) to the table.

I don't understand the latter part of your post. If the subform is bound to a table as you say, no code is needed to modify or add records - unless you are doing something like opening the subform in a manner which doesn't allow that.
 

mike60smart

Registered User.
Local time
Today, 00:12
Joined
Aug 6, 2017
Messages
1,908
Hi JPR

Can you upload a zipped copy of the database?
 

JPR

Registered User.
Local time
Yesterday, 16:12
Joined
Jan 23, 2009
Messages
192
Appreciate your help. Thank you
 

Attachments

  • TestSub.accdb
    448 KB · Views: 85

June7

AWF VIP
Local time
Yesterday, 15:12
Joined
Mar 9, 2014
Messages
5,465
There is no field in table named ID so how can it be used in filter criteria? Fix the Embedded Macro expression.

="[State] = '" & [Screen].[ActiveControl] & "'"
 

mike60smart

Registered User.
Local time
Today, 00:12
Joined
Aug 6, 2017
Messages
1,908
Hi

As June indicated your States table did not have an identifying ID . I added StateID asan Autonumber for the table.

Modified the Subform so that it was based on the Table and Not a Select statement.

Now works OK
 

Attachments

  • TestSub.zip
    42.8 KB · Views: 84

JPR

Registered User.
Local time
Yesterday, 16:12
Joined
Jan 23, 2009
Messages
192
hello,
I have noticed your have changed the code in the macro and added to autonumber but there is still something confusing me.
If I open the form just as form (not from the frmMenu....meaning on the TAB) the combo, works fine although it should show no data (it shows test). If, I open the form regularly as a Subform, then it does not change the records. Thank you
 

mike60smart

Registered User.
Local time
Today, 00:12
Joined
Aug 6, 2017
Messages
1,908
Hi JPR
Don't know what happened there but here with the Form reworked
 

Attachments

  • TestSub.zip
    42.5 KB · Views: 88

Users who are viewing this thread

Top Bottom