This topic is locked

Child Table Autofill from Master

6/9/2007 12:51:56 AM
ASPRunnerPro General questions
Lowkeck authorDevClub member

I know this has been asked a million times but I canot seem to get it to work.
I have a master table called "client_main" with a field called "compname"
In the child table "Client_support" I have a called "compnane".
I wolud simply like to have the "compname" field in the child table automatically filled in from the master table.
Any help would be greatly appreciated.

F
funklet 6/10/2007

If I have read this correctly then I assume you would like a field from another (master) table to show.
The way I would go about this is to manually edit the SQL to include a join to the master table.
If you create the view in SQL server or the Query in Access then you can paste the query into the edit SQL query step and correct any syntax differences, if any.
Just make sure you start with the correct base table that you will be updating any data to if using add / edit etc.
I hope this is of help.

Sergey Kornilov admin 6/10/2007

Lowkeck,
if compname is the field you use to link these two tables you only need to remove compname from the Add page of the child table.

In this case this field will be populated automatically when you add a new child record.

Lowkeck authorDevClub member 6/11/2007

Thanks Guys. If I was to do it this way, will it store the "compname" value from the master table in the actual child table? Or will it simply display the "compname" value in the application?

Sergey Kornilov admin 6/11/2007

It stores compname in the child table. That's how tables are linked.

Lowkeck authorDevClub member 6/11/2007

Sorry, I missed what you were saying in the other message. My tables are linked by a different field called "custno" (numeric field), that is the field I would use to make the innerjoin. In this scenario would the "compname" value still get written to the child table?

J
Jane 6/13/2007

Hi,
to fill compname field on the add page of the detail table use ListOnLoad event on the Events tab for the detail table.

Here is a sample code:

str = "select compname from MasterTable where custno=" & Session(strTableName & "_masterkey1")

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

rsTemp.open str, dbConnection
Session("compname") = rsTemp("compname")

rsTemp.Close : set rsTemp = Nothing


The use Session("compname") as default value for the compname field on the "Edit as" settings dialog on the Visual Editor tab.