How to hyperlink to other subforms on a tab control? (1 Viewer)

Db-why-not

Registered User.
Local time
Today, 16:00
Joined
Sep 17, 2019
Messages
159
I have a main form called Navigation_Form it has a tab control with 2 tabs on it. 1 tab Still_admitted_Form, then 2nd tab with New_PT_Main_Form

The Still_Admitted page is a query that brings up a list of patients still at the hospital with their research_ID.

The New_PT_Main_Form is a data entry form, where you look at 1 patient at a time.

I want the Still admitted Form to have a hyperlink or something similar where you click on the patient Research_ID on the still_admitted page, (Click on Research_ID: 200, then it automatically takes you to the New_PT_Main_Form tab and it brings up the Research_ID: 200 in that form so I can look at that pts detailed records.

I know how to do that with a macro where the hyperlink can open up the New_PT_Main_Form with the correct Research_ID, but I don't want it to open up another form. I want it to navigate to the tab on the already open form and pull up the correct Research_ID on that form. I don't want to have a bunch of different pop up windows. I want everything to be contained within the 1 form.

Any Ideas?

Any Ideas on how to do this.
 

theDBguy

I’m here to help
Staff member
Local time
Today, 14:00
Joined
Oct 29, 2018
Messages
21,358
Hi. If you're using a Navigation Form, check out the BrowseTo method.
 

Db-why-not

Registered User.
Local time
Today, 16:00
Joined
Sep 17, 2019
Messages
159
I tried using the browseto macro but I cant figure out to write the correct path in the macro.
I have the main form navigation_form, then I have 2 tabs all the tabs are called NavigationSubform. The tab that has New_PT_Main_Form is the tab I want to browse to. I keep getting error message about the path not being correct from the browseto macro.

I also want the form to automatically show the research_ID that I clicked on in the still admitted form to go to on the New_PT_Main_form. When I did the openform macro it works in opening the form with record I want but it doesn't let me navigate to other records from the form it opens. I think once I get the browseto macro working it might also do the same thing.
My New_PT_Main_form has navigation buttons (arrows)letting you scroll through all the records.
 

theDBguy

I’m here to help
Staff member
Local time
Today, 14:00
Joined
Oct 29, 2018
Messages
21,358
Hi. BrowseTo can get a little tricky, but it's also hard to tell you what will work for you without seeing what you got because it requires precise syntax. Are you able to post a sample copy of your db?
 

Db-why-not

Registered User.
Local time
Today, 16:00
Joined
Sep 17, 2019
Messages
159
I can post the front end with the forms. I can't share the backend though. Unless I create some fake backend db, but it would take me awhile to make some fake data.
 

theDBguy

I’m here to help
Staff member
Local time
Today, 14:00
Joined
Oct 29, 2018
Messages
21,358
I can post the front end with the forms. I can't share the backend though. Unless I create some fake backend db, but it would take me awhile to make some fake data.
Hi. We could certainly start with that. If you need to generate fake data, I think we have a routine/demo somewhere in here to help make the process easier for you.


PS. If nothing else, just to avoid error messages when running the FE without a BE, maybe also consider posting an empty BE with it.
 

Db-why-not

Registered User.
Local time
Today, 16:00
Joined
Sep 17, 2019
Messages
159
I will try to upload a copy tomorrow with dummy data. For Now I have some screenshots of the forms. Maybe that will help.
Main Form is called Navigation_Form and it has several tabs on it with subforms on each tab.

1st tab is Still_admitted form (based of Still_admitted query). It has a list of pts with Chron# and Research_ID. I want to be able to click on the Chron# or Research_ID and have it browse to the other tab Patient Data Entry, and pull up that specific Research_ID record. Research_ID is my primary Key for most of my tables.

Patient Data Entry tab is based of New_PT_Main_Form.
 

Attachments

  • navigation_Form.jpg
    navigation_Form.jpg
    15.5 KB · Views: 187
  • Patient Data entry design view.jpg
    Patient Data entry design view.jpg
    102.7 KB · Views: 313
  • Patient Data Entry tab.jpg
    Patient Data Entry tab.jpg
    52.4 KB · Views: 296
  • Still_admitted design view.jpg
    Still_admitted design view.jpg
    91.5 KB · Views: 293

theDBguy

I’m here to help
Staff member
Local time
Today, 14:00
Joined
Oct 29, 2018
Messages
21,358
I will try to upload a copy tomorrow with dummy data. For Now I have some screenshots of the forms. Maybe that will help.
Main Form is called Navigation_Form and it has several tabs on it with subforms on each tab.

1st tab is Still_admitted form (based of Still_admitted query). It has a list of pts with Chron# and Research_ID. I want to be able to click on the Chron# or Research_ID and have it browse to the other tab Patient Data Entry, and pull up that specific Research_ID record. Research_ID is my primary Key for most of my tables.

Patient Data Entry tab is based of New_PT_Main_Form.
Hi. Yes, this should be possible. I'll wait 'til you get a chance to post a sample db because BrowseTo requires precise syntax.
 

Db-why-not

Registered User.
Local time
Today, 16:00
Joined
Sep 17, 2019
Messages
159
Here is my FE forms and the BE db. Just need to be linked.
 

Attachments

  • BE_FE_fakedata.zip
    998 KB · Views: 330

Db-why-not

Registered User.
Local time
Today, 16:00
Joined
Sep 17, 2019
Messages
159
I'm currently just using the onclick event openform macro to hyperlink to the other form when you click on the Chron# for the still admitted form.
I keep getting VBA error messages though. They aren't consist, they just happen sometimes. I have someone that also enters data at the same time as me for other patients.

Runtime error ' 440': You can't assign a value to this object and it has a debug button. Then it highlights some VBA code. I have attached the Screenshots of the error message and the code that was highlighted:

Code that was highlighted:

Private Sub Micro_Test_No_AfterUpdate()
Me.Parent.txtbx_Data_last_updated = Now()
End Sub

I have had this code for awhile and not had any problems, not sure why since I added the OpenForm macros now this code is giving me an error.
 

Attachments

  • error-code runtime error_LI.jpg
    error-code runtime error_LI.jpg
    37.1 KB · Views: 254
  • runtime error 440.jpg
    runtime error 440.jpg
    16.5 KB · Views: 294

theDBguy

I’m here to help
Staff member
Local time
Today, 14:00
Joined
Oct 29, 2018
Messages
21,358
Hi. Sorry for the delay. I got sidetracked this weekend. I'll take a look as soon as I get a chance today. Cheers!
 

theDBguy

I’m here to help
Staff member
Local time
Today, 14:00
Joined
Oct 29, 2018
Messages
21,358
Hi. I hope this is what you meant. Cheers!
 

Attachments

  • 121219_LUS_Forms-FE_fakedata.zip
    239.5 KB · Views: 187

Db-why-not

Registered User.
Local time
Today, 16:00
Joined
Sep 17, 2019
Messages
159
Thank you. I tested out the code you put in the file and it works. There is one thing I still wanted it to do. After I click on the link and it takes me to the record on the New_PT_Main_form tab. It only let's me look at the one record. I have navigation buttons that lets me scroll through to each individual patients record on that form. If I click off that form and then go back, then it works again to let me scroll through and see all the records. I want it to always let me scroll to other records after I browseto that form.
 

Db-why-not

Registered User.
Local time
Today, 16:00
Joined
Sep 17, 2019
Messages
159
I had one other question. How would I modify the code for use on another form/ tab within that same navigation_form. I added another tab/ form with a different patient list. I want to do the same thing from the other tab, click on the research-id browse to the New_PT_Main_form with that research_id.
I tried putting that code on the other form but it gave me a vba error.

PHP:
[CODE]Private Sub Research_ID_Click()
Dim strID As String
strID = Nz(Me.Research_ID, 0)
DoCmd.BrowseTo acBrowseToForm, "New_PT_Main_Form", "Navigation_Form.NavigationSubform", "Research_ID='" & strID & "'"
End Sub  [/CODE]
 

Micron

AWF VIP
Local time
Today, 17:00
Joined
Oct 20, 2018
Messages
3,476
Not sure if you realize something because you wrote
I don't want it to open up another form. I want it to navigate to the tab on the already open form and pull up the correct Research_ID on that form.
Whenever you switch navigation tabs you are opening another form. You can only have 1 form open at a time because there is only 1 subform control that holds any form at any particular time. It's a well documented fact, but if you want to prove it to yourself, do the following:
- have the Still Admitted form open and click in a record (might as well be the one with 2 in it)
- enter ?forms!navigation_form.navigationsubform.form.maxofus_number in the immediate window and press Enter when the cursor is at the end of that line. You should get an answer on the line below (2 if that's the record you clicked on)
- switch to the PD entry form then go back to the immediate window. Place the cursor at the end of the same line and press Enter again. What happens?

Maybe that's the reason you're still having issues. Maybe not. I haven't studied your last question but I have reviewed the thread and I don't see where anyone raised this point.
 

Db-why-not

Registered User.
Local time
Today, 16:00
Joined
Sep 17, 2019
Messages
159
Not sure if you realize something because you wrote Whenever you switch navigation tabs you are opening another form. You can only have 1 form open at a time because there is only 1 subform control that holds any form at any particular time. It's a well documented fact, but if you want to prove it to yourself, do the following:
- have the Still Admitted form open and click in a record (might as well be the one with 2 in it)
- enter ?forms!navigation_form.navigationsubform.form.maxofus_number in the immediate window and press Enter when the cursor is at the end of that line. You should get an answer on the line below (2 if that's the record you clicked on)
- switch to the PD entry form then go back to the immediate window. Place the cursor at the end of the same line and press Enter again. What happens?

Maybe that's the reason you're still having issues. Maybe not. I haven't studied your last question but I have reviewed the thread and I don't see where anyone raised this point.

I might not have explained myself correctly. I have the Navigation_form that has tabs with nested subforms. One of the tabs on the navigation_form is the patient data entry, when you click on that tab it shows my New_Pt_Main_Form tab. My Still admitted tab shows a list of patients with their research_ID. I wanted it to be able to click on the research_ID, then have it move the focus to the New_Pt_Main_Form tab with that research_ID number pulled up on that form. I was able to get it to work with the openform macro, but it wouldn't just move the focus to the New_Pt_Main_Form tab it would completely open up another form. theDBguy was able to help me though, he wrote some VBA code with browseto instead of the Macro to get it to do what I want.


It still doesn't completely do what I want. When it browses to the New_Pt_Main_Form tab it pulls up the research_ID that I clicked on, but then it doesn't let me navigate to other records (other research_IDs) after. I have to click off that tab and come back to it before it lets me view/ scroll through all the records connected to that form. I could leave it that way, it basically works but I want to try to get it exactly how I want it.

TheDBguy was awesome and helped me get this far.
 

theDBguy

I’m here to help
Staff member
Local time
Today, 14:00
Joined
Oct 29, 2018
Messages
21,358
I had one other question. How would I modify the code for use on another form/ tab within that same navigation_form. I added another tab/ form with a different patient list. I want to do the same thing from the other tab, click on the research-id browse to the New_PT_Main_form with that research_id.
I tried putting that code on the other form but it gave me a vba error.

PHP:
[CODE]Private Sub Research_ID_Click()Dim strID As StringstrID = Nz(Me.Research_ID, 0)DoCmd.BrowseTo acBrowseToForm, "New_PT_Main_Form", "Navigation_Form.NavigationSubform", "Research_ID='" & strID & "'"End Sub  [/CODE]
Hi. What was the error message? Can you post a copy of the latest version of your db? Thanks.
 

theDBguy

I’m here to help
Staff member
Local time
Today, 14:00
Joined
Oct 29, 2018
Messages
21,358
Hi. Without seeing what you added, I won't be able to answer your other question, but here's an updated copy of your FE that allows going to other records in the subform. Hope it helps...
 

Attachments

  • 121219_LUS_Forms-FE_fakedata.zip
    242.1 KB · Views: 305

Db-why-not

Registered User.
Local time
Today, 16:00
Joined
Sep 17, 2019
Messages
159
Hi. Without seeing what you added, I won't be able to answer your other question, but here's an updated copy of your FE that allows going to other records in the subform. Hope it helps...
Thanks, I will look at this. I probably wont be able to look at it till Monday.
 

Users who are viewing this thread

Top Bottom