This topic is locked

Create Event with values from two tables

1/5/2010 3:06:58 PM
ASPRunnerPro General questions
D
danivale author

Hi to everybody!

I have a question for all you:
I have two tables in my db
Project and Purchase
in the Purchase table I have all the records related to the projects purchases
For example my purchase page list is like this:
Project A - Hardware - 50,00

Project A - Software - 450,00

Project A - work train tickets - 60,00

Project B - Hardware - 250,00

Project B - Software - 300,00
etc..
In my project page list I have a column containing the link to all purchases (with childnumber).

So if I click the purchase link for the project A I see something like this:
Project A - Hardware - 50,00

Project A - Software - 450,00

Project A - work train tickets - 60,00
Ok everything is ok.

But now I'm creating an event "before record updated".

It must work in this way:

  1. the project master table contains the value "budget"
  2. if the sum of purchases is > then project budget, the inline edit must fail
    My problems are:
  3. how to retrieve the budget of the project in the purchases list!!

    I tried to change the purchases query using a join with project (to use values("budget")) but during the update it generates an error.
  4. how to make the sum of all the values("price"). I can retrieve only one at once.
    Thanks

J
Jane 1/7/2010

Hi,
use Before record updated events to select these values from database.

Here is just a sample:

Set rstmp = dal.Project.Qeury("MasterKey=" & Session(strTableName & "_masterkey1"),"")
budget = rstmp("FieldName")
rstmp.close

set rstmp=nothing
D
danivale author 1/8/2010

Ok I try!!



Hi,
use Before record updated events to select these values from database.

Here is just a sample:

Set rstmp = dal.Project.Qeury("MasterKey=" & Session(strTableName & "_masterkey1"),"")
budget = rstmp("FieldName")
rstmp.close

set rstmp=nothing


D
danivale author 1/13/2010

The problem is how to make the sum of all the values("price")!



Ok I try!!

J
Jane 1/13/2010

Here is a sample:

str = "select sum(FieldName) from TableName where MasterKey=" & Session(strTableName & "_masterkey1")"

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

rstmp.open str,dbConnection
budget = rstmp(0)
rstmp.close

set rstmp=nothing