UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
 
   Reply to this topicStart new topic
> Making Hyperlink Record Open Tabbed Form To Specific Record, Access 2016    
 
   
jimmychang
post Mar 6 2018, 08:46 AM
Post#1



Posts: 8
Joined: 6-March 18



Hello all, I hope this is the right section to post this,

I am a first time poster here and a novice access user at best. I am working on a school project and I have kind of hit a brick wall. As I am not well versed in VBA or the finer details of Access, I was suggested to ask the fine folks here for some advice on how to tackle my issue.

I will start by listing some background information but I will try to be concise and only include relevant information:

First, I have the following entities and their relationships:


Second, here is a description of my forms:

I have a "Main" form which has navigation tabs ("Donors" and "Donations"). Each tab opens different forms within a subform on the Main form.

The Donors form contains tab control. One of the tabs is "Donation History" which has a subform/table which shows a list of all the donations a particular donor has made. The DonationID is part of this table but it is hidden from the user:


The Donations form contains controls for DonationHeader attributes and a subform/table which shows DonationLine attributes:


---

The problem:

I do not want users to edit donation data in the Donation History subform so I have adjusted the properties so users cannot change values here. However, I want the user to be able to click an attribute within this table (for example, the date) and it will switch to the Donations tab and present the corresponding DonationHeader record and the associated DonationLineItem records.

I have tried a few different approaches but ultimately I am starting to confuse myself. The two layers of tabs (Donors + Donation History) combined with the sub-subforms, combined with my inexperience with VBA has really thrown me for a loop.

Can anyone help guide me to a solution? Thanks in advance and if I need to provide more info just let me know.

P.S. I know my form design is bad. This is my first attempt at access and I am still heavily tinkering with it. ohyeah.gif
This post has been edited by jimmychang: Mar 6 2018, 08:57 AM
Reason for edit: We do not support external links to images. Thank you for reading and following our guidelines
Go to the top of the page
 
ranman256
post Mar 6 2018, 12:02 PM
Post#2



Posts: 862
Joined: 25-April 14



you really dont need any VBA.
You can open the forms for Non editing....
docmd.OpenForm "myForm",acNormal,,[id]=" & txtID,acFormReadOnly

or allow edits
docmd.OpenForm "myForm",acNormal,,[id]=" & txtID


subforms are joined on the master form ID.
Go to the top of the page
 
theDBguy
post Mar 6 2018, 12:11 PM
Post#3


Access Wiki and Forums Moderator
Posts: 72,447
Joined: 19-June 07
From: SunnySandyEggo


Hi Jimmy,

Welcome to UtterAccess!
welcome2UA.gif

There are ways to refer to a control anywhere on a form. It can be from a subform to the main form or main form to the subform. You can also refer to a control on a form using absolute addressing. For example, the syntax Forms!FormName.SubformName.Form!ControlName can be used anywhere on a form to refer to a specific control on the same form.

You can also use this knowledge to add a hidden textbox on the form to store the value you want to use for other processes. Having a hidden textbox on the main form can sometimes make it easier to refer to the value from anywhere on the form too.

Hope it helps...

--------------------
Just my 2 cents... "And if I claim to be a wise man, it surely means that I don't know" - Kansas
Microsoft Access MVP | Access Website | Access Blog | Email
Go to the top of the page
 
zaxbat
post Mar 6 2018, 12:32 PM
Post#4



Posts: 956
Joined: 26-January 06
From: .....the wiregrass (either you know or you don't)


On the history tab where you do not want any changes just set each textbox in the subform to mytextbox.locked = true that will stop the user from making changes....but it will still allow gotfocus event so you can trigger the tab change. Got it?
If you have been toggling the enabled or allow edits properties....I would not recommend that approach.
This post has been edited by zaxbat: Mar 6 2018, 12:32 PM

--------------------
Kindest regards, and Cheers!
ZAX

A picture is worth a thousand words and a zipped DB is worth a thousand pictures.
Oh, and....please don't disappear into the Twilight Zone.... Holler back with your results!
Go to the top of the page
 
jimmychang
post Mar 6 2018, 04:00 PM
Post#5



Posts: 8
Joined: 6-March 18



Thanks for the initial responses guys. I have already figured out how to prevent the user from making edits to the donation history table, so that isn't much of an issue. But my reason for doing so segues into the problem I am trying to resolve:

My main problem here is creating a link in the Donation History subform/table so, when clicked, will open the donations tab to the corresponding DonationHeader record. I'm just not sure how to accomplish this. I have the DonationID in the Donation History subform/table (it is hidden) because I believe it is key in solving this issue. I imagine this problem would be solved by perhaps creating an On Click event which switches to the Donations tab and opens the DonationHeader record where DonationID = DonationID from the clicked Donation History record. I'm just having issues implementing this in either macro or VBA form.
Go to the top of the page
 
jimmychang
post Mar 6 2018, 04:28 PM
Post#6



Posts: 8
Joined: 6-March 18



@theDBguy

Thanks for clarifying the syntax a little. Although, my gut tells me that the syntax for my particular control might be a little deeper. I have the Main form, which has a subform 'NavigationSubform', that is filled with the 'Donors' form, which has the page/tab 'DonationHistory', which has a subform/table 'DonationHistorySubform'. (Even I'm starting to get confused, lol!)

Would accessing DonationID (hidden in the picture, but it is infact in the Donation History table) look something like this:

Forms!Main.NavigationSubform.Forms!Donors.Pages!DonationHistory.Forms!DonationHistorySubform!DonationID

Let me know if that looks right. If so, could I set a TempVar to that, use a module to RunCode to switch to the Donations tab, then somehow locate the record using the TempVar? (If so, I'm not sure what the macro command would be to locate/open the record)

Hopefully that's not too confusing. Might be approaching this the wrong way.
This post has been edited by jimmychang: Mar 6 2018, 04:30 PM
Go to the top of the page
 
theDBguy
post Mar 6 2018, 05:34 PM
Post#7


Access Wiki and Forums Moderator
Posts: 72,447
Joined: 19-June 07
From: SunnySandyEggo


Hi,

The syntax for referring to a control on a subform, which is located in a subform on a main form would look more like this:

Forms!MainFormName.FirstSubformName.Form!SecondSubformName.Form!ControlName

Hope it helps...

--------------------
Just my 2 cents... "And if I claim to be a wise man, it surely means that I don't know" - Kansas
Microsoft Access MVP | Access Website | Access Blog | Email
Go to the top of the page
 


Custom Search
RSSSearch   Top   Lo-Fi    25th June 2018 - 04:34 AM