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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Displaying the current record from a datasheet using tabs

Status
Not open for further replies.

kevink

Programmer
Nov 23, 1999
53
IE
I have a form on which there are several tabs. Each tab contains a subform (which are not linked to the parent form). One subform contains a list of all the names in the database (datasheet view), another subform shows a specific clients details (form view). <br>
<br>
Is there anyway where I can select a client from the datasheet view and when I go the next tab, that particular clients details will be displated on the form? I have this feeling that I'm missing something really simple .....<br>
<br>
Thanks,<br>
<br>
Kevin
 
Try this: I just made a simple example.<br>
I put a TAB control on my main form.<br>
I added a Subform to TAB 1. I set the recordsource to the &quot;client&quot; table.<br>
I added a second subfrom to TAB 2 it set it's record to<br>
the other table.<br>
I then double clicked on the subform in TAB 1 to bring up properties.<br>
The I put this code in the On_click event of it.<br>
--------------------------------------<br>
Private Sub Form_Click()<br>
Dim SQL As String<br>
SQL = &quot;Select * From [Customers] Where CustomerID = &quot; & Me![CustomerID]<br>
Forms![Form2]![Customers subform].Form.RecordSource = SQL<br>
End Sub<br>
-------------------------<br>
<br>
So when you click on a client in the TAB 1 subform and click on TAB 2 it will show the details.<br>
Now both tables have to have a Common field I called CustomerID.<br>
<br>
OK<br>
<br>
<br>
<p> DougP<br><a href=mailto: dposton@universal1.com> dposton@universal1.com</a><br><a href= > </a><br>
 
Maybe I can give you an alternate view/solution to the problem:<br>
<br>
I just had my initial introduction to Tabs Forms on the project I am working on. I discovered that regardless if the Forms (or subforms) are linked, that all the Forms in all the tabs are opened when the intial tab form is opened and never opened again when you tab back and forth. This was a problem since I was building SQL in the On Open routines and the subsequent tabs required key data from the prior tabs (data entry application). I went to saving my keys as globals and building a global function (for each key) to return the key(s), then using the function as the search criteria in the control source of the Form(s) to eliminate the need to build the SQL. When using tabs , I could not find a logical/consistent place to build the SQL to override the Forms Query.<br>
<br>
Add on question: Is there a way to restrict opening all the Forms on initial entry? Is there a way to open and close the form on each tab when exiting or entering the tab?
 
I believe I saw it suggested that you load forms only when the tab opened when very large record sets were involved. I thing the method was something like loading the form's RecordSource through code entered into the Tab's OnGotFocus event.<br>
<br>
???
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top