This topic is locked

If Field Is Not Empty Then Add Part Of Record To Another Table

3/18/2013 1:59:49 PM
ASPRunnerPro General questions
M
mitzi author

Hi,
here is what i am trying to accomplish:
I have two tables:
customers and complaints
customers table:

Id

Address

Complaint

million other fields etc.
complaint table

address

complaint

some other fields
I need toAFTERinserting record into the Customer table ALSOinsert "address" and "complaint" into the Complaintstable ONLY if "complaint field" was populated in the customer table:
here is my code:

I know it is totally wrong, but i need some directions here on how to solve the issue
----------------------------------------------

'** Insert a record into another table ****

if values("Complaint") is not NULL then
BeforeAdd = true

dim dal_table

set dal_table=dal.Table("Complaints")

dal_table.Employees=values("EmployeeName")

dal_table.Address=values("Address")

dal_table.Complaint=values("Complaint")

dal_table.OwnerID=values("OwnerID")

dal_table.Add()
else
BeforeAdd = false

end if

rsExists.Close : set rsExists = Nothing
-------------------
this is the error:
[font="Arial"][size="2"]Object required[/size]
[font="Arial"][size="2"][size="2"]where i am wrong can someone please help?[/size]

[/size]

M
mitzi author 3/18/2013

Apparently I have managed to use this piece of code:
'** Insert a record into another table ****

if values("Complaint")= "" then

Response.Write "No complaints entered"

else
dim dal_table

set dal_table=dal.Table("Complaints")

dal_table.EmployeeName=values("Employees")

dal_table.Address=values("Address")

dal_table.Complaint=values("Complaint")

dal_table.OwnerID=values("OwnerID")

dal_table.Add()
end if

-----------------------
It works:

  1. if enter something in complaint field - it adds record to complaints Tables,
  2. if I do not add anything in the complaint field it DOES not add any record into the complaint table (but does not show the response .write " message...
    something tells me I am missing something here.
    I would really appreciate if I can get help