This topic is locked

Accessing Master Keys on Detail Page

4/16/2009 10:52:06 AM
ASPRunnerPro General questions
Stu author

I have a MASTER table "CompanyAddressCodeValid" and it links to a DETAIL table "Contacts"
In the MASTER table my key name is "Location Code" and in the DETAIL table its also "Location Code"
I need to reference something from my MASTER table when an Add page for the DETAIL table is Displayed. I want to give one of the fields a Default Value with the option for the user to change the Default to something else.
I just need the MASTER key value so I can write my Queries to get that value.
I have tried every syntax to get that MASTER Key. So, I have resorted to trying to write it to the screen to make sure I've got the right reference.
Example, as a code snippet in the Add page and even in the list page of the DETAIL table:-
Response.Write Session("CompanyAddressCodeValid" & "_masterkey1")
I don't get anything!
I must have the wrong syntax or maybe the value isn't available. Please advise me.
(Alternatively, I can present my default value by using the Lookup Wizard for that field in the Add screen but I want the user to type their own. I can use "Add a Value" to the Lookup Table because its a GroupBy Query. I can do the Default Value b y Query if only I can reference the MASTER Key)

Stu author 4/16/2009

Answering my own question again!
Use the code :-
Session("SomethingINeedLater")= rs("TheNameOfTheFieldIWantTheValueOf")
You can put this code in the List Page After Record Processed EVENT
Then, in the Add Page Before Process EVENT you can reference Session("SomethingINeedLater")
I can then write a Query with that Session value
Any other alternatives, if its not too much trouble would be useful.
Regards,
Stu

I have a MASTER table "CompanyAddressCodeValid" and it links to a DETAIL table "Contacts"

In the MASTER table my key name is "Location Code" and in the DETAIL table its also "Location Code"
I need to reference something from my MASTER table when an Add page for the DETAIL table is Displayed. I want to give one of the fields a Default Value with the option for the user to change the Default to something else.
I just need the MASTER key value so I can write my Queries to get that value.
I have tried every syntax to get that MASTER Key. So, I have resorted to trying to write it to the screen to make sure I've got the right reference.
Example, as a code snippet in the Add page and even in the list page of the DETAIL table:-
Response.Write Session("CompanyAddressCodeValid" & "_masterkey1")
I don't get anything!
I must have the wrong syntax or maybe the value isn't available. Please advise me.
(Alternatively, I can present my default value by using the Lookup Wizard for that field in the Add screen but I want the user to type their own. I can use "Add a Value" to the Lookup Table because its a GroupBy Query. I can do the Default Value b y Query if only I can reference the MASTER Key)

Stu author 4/22/2009

Grrrrr!!!!
The code I suggested doesn't really do the trick. What I want to access is the Master Key that the Detail Record belongs to.
The manual, help and lost of replies on the forum say to use the form:-
Response.Write Session($mastertablename & "_masterkey1")
But what is DOESN'T tell you is to use the FULL TABLE NAME!!!!
For example, my Detail table is "WebChat". using Response.Write Session("WebChat_masterkey1")DOES ABSOLUTELY ZILCH!!!
In most dialogues we use the Table name which drops the "dbo." from the front of the name. For example the REAL name of that table is:-
"dbo.WebChat" and NOT "WebChat".
Hence, using Response.Write Session("dbo.WebChat_masterkey1") WORKS!!!!!!
I just wish it had been made more obvious!
I hope this helps other people.
Regards,
Stu
BTW - I am doing some incredible things with ASP Runner and so I actually have nothing but praise for the product

I just wish the Help was a bit more explicit with real world examples like "If you table name is X and your key is Y then your code looks like......"

Answering my own question again!

Use the code :-
Session("SomethingINeedLater")= rs("TheNameOfTheFieldIWantTheValueOf")
You can put this code in the List Page After Record Processed EVENT
Then, in the Add Page Before Process EVENT you can reference Session("SomethingINeedLater")
I can then write a Query with that Session value
Any other alternatives, if its not too much trouble would be useful.
Regards,
Stu

Admin 4/22/2009

Correct syntax is SESSION(strTableName & "_masterkey1"). This way you don't have to worry about table prefixes.
This will be fixed in ASPRunnerPro 6.1 manual.