This topic is locked

Update Master record when new child record added

7/2/2009 5:47:54 AM
ASPRunnerPro General questions
J
jeremyb author

My database is simple, it has a Master record that has:
Invoive No

Client

Employee

Money

Last Updated

......
and is linked to another table - comments - by way of the Invoice No.
The Comments table just has on it

Invoice No

Comments

Update_by

Date
When a new comments record is added I want the Master record 'Last_Updated' field to be updated with the date that the new 'Comments' record has been added.
I know this is a 'After Record added' event, but I don't know how to code this.
Assistance appreciated
Jeremyb

J
Jane 7/2/2009

Hi,
here is a sample:

str = "update [MasterTable] set [Last Updated]='" & values("Date") & "' where [Invoive No]=" & values("Invoive No")

dbConnection.Execute str

J
jeremyb author 7/2/2009

Jane
I have entered
str = "update [Aged Debtors] set [Last_Updated]='" & values("Date") & "' where [Transaction Reference]=" & values("Transaction Reference")

dbConnection.Execute str
within the After Record Added section and nothing happens.
Any idea?
Jeremyb

Sergey Kornilov admin 7/2/2009

Jeremy,
instead of executing this SQL query print it on the web page to see if it looks right. You can also test it against your database to see if it works.
response.write str command will print the query for you.

J
jeremyb author 7/4/2009

Sergey
Sorry but I don't understand what you are suggesting I do.
Jeremy

J
Jane 7/6/2009

Jeremy,
try to print this query on the page:

str = "update [Aged Debtors] set [Last_Updated]='" & values("Date") & "' where [Transaction Reference]=" & values("Transaction Reference")

Response.write str



and then execute it in the database.

J
jeremyb author 7/7/2009

Jane
I am sorry but I don't understand what you are asking me to do. How do you print query on the page. Do I use ASP snippets ???

Are you wanting me to create a new field with this code in it to populate
Sorry but this is making no sense to me.

J
Jane 7/8/2009

Hi,
to print query on the page use Response.Write statement:

str = "update [Aged Debtors] set [Last_Updated]='" & values("Date") & "' where [Transaction Reference]=" & values("Transaction Reference")

Response.write str

J
jeremyb author 7/8/2009

Hi,

to print query on the page use Response.Write statement:


Jane,
Not having a great deal of success understanding where you want me to put this, I added it to the Event -
Still no joy nothing got added to the main table.
Would it help if I opened a ticket?
Jeremy

Sergey Kornilov admin 7/8/2009

Yes, post your application to Demo Account and open a ticket at http://support.xlinesoft.com sending your Demo Account URL for investigation.