This topic is locked

Master Table's values

2/16/2009 8:32:30 PM
ASPRunnerPro General questions
Y
yairilan author

Hi,

I need help with define a default value that is being taken from a master table - but not "masterkey1".

For example - I have Customers, Projects and Jobs related as:

Customers - is a master table of - Projects

Projects - is a master table of - Jobs.

When I open a new job - the "Project ID" is being insert automaticlly, BUT, I need also that the "Customer ID" from the Projects table will be put automaticlly as well (Because of Authorization matters ).

The BUG I have is that what gets into this field is the "Owner_Id" from the Customers table and when Admin user is Loged-In it puts his "Owner_Id" and not the real Customer.

Can someone help???????

J
Jane 2/17/2009

Hi,
I recommend you to fill Customer ID in the Before record added event on the Events tab directly.

Select correct value from Projects table and save it in the Customer ID field.

Here is a sample:

str = "select [Customer ID] from Projects where [Project ID]=" & Session(strTableName & "_masterkey1")

Set rstmp = server.CreateObject("ADODB.Recordset")

rstmp.open str,dbConnection

dict("Customer ID") = rstmp("Customer ID")

rstmp.close

set rstmp=nothing

Y
yairilan author 2/18/2009

Tx Very very much!!!
By the way - If I want that the Field's value will be written inside the text area in the form, what should I use?

J
Jane 2/19/2009

Hi,
I'm not sure that I understand your question.

Do you want to save this value in another field? Or do you want to show this value on the add page directly? Please clarify.

Y
yairilan author 2/19/2009

Sorry ...

I ment - how can I use this code to get a value from a table and show this value on the add page directly when it's open ( in a text box ).

Tx again,

Yair.

J
Jane 2/20/2009

Hi,
you should select value from database in the Add page: Before process event, save it in the session variable and then use this session variable as default value on the "Edit as" settings dialog on the Visual Editor tab.

str = "select [Customer ID] from Projects where [Project ID]=" & Session(strTableName & "_masterkey1")

Set rstmp = server.CreateObject("ADODB.Recordset")

rstmp.open str,dbConnection

= rstmp("Customer ID")

rstmp.close

set rstmp=nothing