This topic is locked

Add Event after record

3/26/2012 10:55:46 AM
ASPRunnerPro General questions
R
Raptor author

Sorry for posting this in the wrong section. I hope someone can help.
I have 2 tables [Patient Information] and [Notes] that are linked by a column called PatientID. When I add a record on the patient information page I would like to also add a note that a new record is added. Here is the code that I am trying but it is leaving off the PatientID value. Also the patientid value is automatically assigned when the recorded it added the database.
'** Insert a record into another table ****

dal.Notes.PatientID=Session(strTableName & "_masterkey1")

dal.Notes.Note="New Claim added"

dal.Notes.Date=[Date]

dal.Notes.Priority="New Claim"

dal.Notes.Enteredby=SESSION("UserID")

dal.Notes.Followup=[Date]

dal.Notes.Add()
AfterAdd=true
Thank You for your help.

Sergey Kornilov admin 3/26/2012

A few notes:

  1. make sure that Session(strTableName & "_masterkey1") is populated with the right value. Print it on the web page to ensure that.

    You can add the following in the beginning on the event code:

Response.Write "Table: " & strTableName & " Session: " & Session(strTableName & "_masterkey1")

Response.End


2. [Date] doesn't look right. Use Now()

dal.Notes.Followup=Now()


3. AfterAdd = true is not required and doesn't make much sense as well.

R
Raptor author 3/26/2012

Thank You Sergey for responding. I tried this but get an error. I must be missing something.
Response.Write "Patient Information" & strTableName " Session: " & Session(strTableName & "_masterkey1")

Response.End
AfterAdd=true

Sergey Kornilov admin 3/26/2012

I've updated the code. Give it another try.
Posting error message will be helpful as well.

R
Raptor author 3/26/2012



I've updated the code. Give it another try.
Posting error message will be helpful as well.


Here is the message I get.
Table: dbo.Patient Information Session:

Sergey Kornilov admin 3/27/2012

I guess Session(strTableName & "_masterkey1") variable is not populated where you trying to use it. Since this variable is empty no value will be assigned to PatientID field.

R
Raptor author 3/27/2012

patientID is assigned to the account after you click the save button. I wonder if there is a why to grab the patientid after the save from the session?

Sergey Kornilov admin 3/27/2012

The typical scenario is to save some value to session variable in one of events and then use it in another event. I guess that session variable that you trying to use were not populated yet.