I have a table "defaults" that is intended to be populated by user supplied defaults for several forms and their record source tables.
By the structure below not all fieldnames are associated with all tables.
ie. tbl_State might contain data for StName but no other data would appear for anything but that StName field.
Example Table: "defaults"
[li]TableName PipeType StName PipeSize CountyName [/li]
[li]State null CO null null[/li]
[li]County null null null Denver[/li]
[li]Pipe Surface null 18 null [/li]
[li]Pipe Intermed null 7.5 null [/li]
Objective:
I would like to create an SQL query on the fly from a command button. The command button already collects the form name and the underlying recordsource which is the tableName.
I would like to select from this "defaults table" rows that match the corresponding table name and then only the fields in those rows that contain data. Almost like an array.
This way I would have 2 rows from the table "Pipe" and display only the fields "PipeType" and "PipeSize" as shown in the last two lines of the example table
I would like to use this recordset to insert these default values into another table using these field Names and values and the Primary key appropriate to that table.
So How can I create this on the fly,
Capture the field names and row data and then insert this into another table?
The goal is to make this code very generic so that which ever form or subform the user is on when they use a cmd button "Use Defaults" the code will execute.
Setting defaults in tables or forms will not work as some tables will require multiple rows to insert. Not all users of a form will have the same defaults.
I think this is an interesting problem help or suggestions are welcome! thanks
By the structure below not all fieldnames are associated with all tables.
ie. tbl_State might contain data for StName but no other data would appear for anything but that StName field.
Example Table: "defaults"
[li]TableName PipeType StName PipeSize CountyName [/li]
[li]State null CO null null[/li]
[li]County null null null Denver[/li]
[li]Pipe Surface null 18 null [/li]
[li]Pipe Intermed null 7.5 null [/li]
Objective:
I would like to create an SQL query on the fly from a command button. The command button already collects the form name and the underlying recordsource which is the tableName.
I would like to select from this "defaults table" rows that match the corresponding table name and then only the fields in those rows that contain data. Almost like an array.
This way I would have 2 rows from the table "Pipe" and display only the fields "PipeType" and "PipeSize" as shown in the last two lines of the example table
I would like to use this recordset to insert these default values into another table using these field Names and values and the Primary key appropriate to that table.
So How can I create this on the fly,
Capture the field names and row data and then insert this into another table?
The goal is to make this code very generic so that which ever form or subform the user is on when they use a cmd button "Use Defaults" the code will execute.
Setting defaults in tables or forms will not work as some tables will require multiple rows to insert. Not all users of a form will have the same defaults.
I think this is an interesting problem help or suggestions are welcome! thanks