Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Tab control with subforms not showing same record

Status
Not open for further replies.

bluegnu

Technical User
Sep 12, 2001
131
GB
Ok, I have form with 3 tabs on it. Within each tab is a different subform.

If I input a data into the subform in tab 1 this will (for example) create record number 1, I want to be able to switch to tab 2 and that subform should still be on the record number 1, just allow me to input different data.

Problem is, when I switch to tab 2 and type something in it creates record number 2 (for example). The only way I can get tab 2 to show record number 1 is to close the form and reopen it.

I'd like not to have to do that.

I hope that makes sense. Thanks in advance for any help you can give me.
 
To make this work you are going to make sure that you create tables based on the subform information.

These subforms need to have a relationship of some sort to your main table. To do this, for instance you could use the ID or primar key field added to the subforms. For instance... say your primary key is ID on the main form, you would create an entry in your subform for ID (make sure this field is not the primary key).

Now, after that is all done with all the subforms you create, then you need to make a relationship pointer to make sure that the ID fields keep your records together.

So go to the relationships and make a relationship from the ID on your mainform to the ID on your subform... This will link the form and subform together by the ID field.

Once you have all that done... then you should be able to add that subform to your form just make sure you include the ID field on the subform somewhere... you can hide the ID field if you wish, but it must be on the form for it to work...

Hope I got everything and that it is what you are looking for...

Good Luck!
Chance~
 
Thanks for the response.

I think I might not have made much sense in my previous post, but I'm struggling to explain my problem.

I have a form which has 3 tabs on it. Each tab has a subform within it.

The form relates to table A and the subforms all relate to table B.

Table A has a one to many relationship with table B and this is working fine.

Say I create a new record in my form, this will create unique record number 1 in Table A. I then type something in the subform of the first tab, this creates record number 1 on Table B.

If I then click onto the second tab I want this to display record number 1 of table B also, but it does't. What it does is display an empty record so when I type in it it would creates record number 2 in Table B.

In order for me to display record number 1 of table B in the second tab I have to close the form and reopen it, then it does display the correct record.

I don't want to have to put record selectors on my subforms, I just want to type something in tab 1 and switch to tab 2 and type on the same record without having to close the form.

I'm sure there must be a simple way around this, but I'm missing something obvious.

I hope this makes more sense, I don't know how else to dsicribe it!

thanks
 
I do understand what you are saying now... although I am confused as to why you would need to do that?

Sounds like a focus issue... and possibly a form refresh (after update) issue...

anyone else have an idea?

Chance~


 
Thanks OD, I worked it out now:

Private Sub SubForm()

Me![SubForm].Form.Requery

End Sub

Seems to do the job.
 
2 months later and I'm experiencing the dilemma of linking a subform to another subform. I hope bluegnu and OverDrive are still out there...where would the code for requerying belong?

I have a main form with a tab control that has 2 tabs/pages. Each page has a subform that links back to one table. The main form links to the subform on RecordNumber just fine based on the master and child field links but I'm having difficulties linking the second subform to the first subform on the master and child link field properties. The child link field for the second subform is RecSub and the master link field for the second form is [Subform1].[Form]![RecSub]. There is an example of this in the sample Northwinds database using the Customer Order form but I can't seem to replicate it. Microsoft also makes note of this in the following knowledge base article:


Please help...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top