TAB control form

Deborahp
Lounger
Posts: 35
Joined: 21 Apr 2010, 19:19

TAB control form

Post by Deborahp »

I need to create a form that will have several tabs on it.
Each tab will represent 1 of our practices. Total of 12 practices.
Is there a way that when I click the tab, it will only display that practice information?
The information will be all the equipment that is in that practice.
Thanks...

User avatar
HansV
Administrator
Posts: 78542
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: TAB control form

Post by HansV »

I assume that each tab needs to display multiple records. Is that correct?
Best wishes,
Hans

Deborahp
Lounger
Posts: 35
Joined: 21 Apr 2010, 19:19

Re: TAB control form

Post by Deborahp »

Yes, you are correct.

Deborahp
Lounger
Posts: 35
Joined: 21 Apr 2010, 19:19

Re: TAB control form

Post by Deborahp »

I created a tab control and then created a subform and inserted in the tab.
Is there a way to link the tab name to the subform to extract on the records based off that practices id number?

User avatar
HansV
Administrator
Posts: 78542
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: TAB control form

Post by HansV »

First, create a form that displays the info that you need for all practices.
This will become a subform, so call it (for example) sfrmEquipment.
Next, create an unbound form.
Place a tab control on the form, and name it tabPractices.
Create a tab for each of the practices, with the appropriate caption for each tab.
Place the form sfrmEquipment as a subform on the new form, but not in the tab control.
Then drag the subform on top of the tab page. This way, the subform will be visible on every tab page.
Select the tab control as a whole, by clicking in the bar at the top, to the right of the tabs.
Activate the Event tab of the Properties window/pane.
Click in the On Change event.
Select Event Procedure from the dropdown list.
Click the ... button to the right of the dropdown arrow.
This will create an event procedure in the form module:

Code: Select all

Private Sub tabPractices_Change()

End Sub
For the next part, I will assume that each practice is uniquely identified by a number field PracticeID, and I will use some made-up numbers for the PracticeIDs of the practices. You'll have to modify the code for your situation.

Make the code look like this:

Code: Select all

Private Sub tabPractices_Change()
  Dim arrID
  ' These are the IDs of the practices in the order they should
  ' be displayed in the tab control
  arrID = Array(1, 3, 4, 7, 8, 10, 11, 12, 15, 16, 19, 29)
  With Me.sfrmEquipment.Form
    .Filter = "PracticeID=" & arrID(Me.tabPractices)
    .FilterOn = True
  End With
End Sub
Best wishes,
Hans

Deborahp
Lounger
Posts: 35
Joined: 21 Apr 2010, 19:19

Re: TAB control form

Post by Deborahp »

PERFECT!!!
Thank you so much.

Deborahp
Lounger
Posts: 35
Joined: 21 Apr 2010, 19:19

Re: TAB control form

Post by Deborahp »

Got another question.
We have a program that will allow us to proxy into someone else's computer.
Once I filter out the equipment for the practice (which works so great), I want to click on their P# and automatically start the VNC program and connect.
How can I do this?

User avatar
HansV
Administrator
Posts: 78542
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: TAB control form

Post by HansV »

Do you know the command line or instruction for starting the VNC program?
Best wishes,
Hans

Deborahp
Lounger
Posts: 35
Joined: 21 Apr 2010, 19:19

Re: TAB control form

Post by Deborahp »

we got to our intranet site and enter the following in the address bar...
http://pa0xxxxx:5800/" onclick="window.open(this.href);return false;

The pa0 is the p# on the computer.

User avatar
HansV
Administrator
Posts: 78542
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: TAB control form

Post by HansV »

Try code like this in the On Click (or On Dbl Click if you prefer) event procedure for the P# field:

Application.FollowHyperlink "http://pa0xxxx:" & Me.[P#] & "/"

Replace P# with the actual name of the P# text box.
Best wishes,
Hans

Deborahp
Lounger
Posts: 35
Joined: 21 Apr 2010, 19:19

Re: TAB control form

Post by Deborahp »

I am getting an error message that it can not locate the server or proxy setting.
So, I added a line to open our intranet...which works and then put the line for the VNC code.
Still getting same error message.
Any suggestions???

User avatar
HansV
Administrator
Posts: 78542
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: TAB control form

Post by HansV »

Could you temporarily change the line

Application.FollowHyperlink "http://pa0xxxx:" & Me.[P#] & "/"

to

MsgBox "http://pa0xxxx:" & Me.[P#] & "/"

This will cause the code to display the URL in a message box. Does it look correct?
Best wishes,
Hans

Deborahp
Lounger
Posts: 35
Joined: 21 Apr 2010, 19:19

Re: TAB control form

Post by Deborahp »

I finally got the url to work. It was my fault...typo!! Thanks...
Got another question about the tab control.
When I open the form, the first tab has all the records appearing. Is there a way to make it blank or show only the records for that tab?
It works great once you click on the tab or click another practice tab....just when you open it for the first time, all the records appear.

User avatar
HansV
Administrator
Posts: 78542
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: TAB control form

Post by HansV »

You can call the tabPractices_Change event procedure when the form opens, in the On Load event procedure:

Code: Select all

Private Sub Form_Load()
  Call tabPractices_Change
End Sub
Best wishes,
Hans