G
Guest
Problem: Recognizing the value of a textbox on a form as the FROM table name in an INSERT INTO query
Situation: DB has multiple tables, all identical structures. Each is generated from a page in a Visio drawing. Access form displays all fields of a table and allow user to switch tables. One of the purposes of the form is to allow user to move a record to a different table. (Don't worry about duplicate records or keys here.) The code below will read the INSERT INTO target as a control on the form and read several textbox control values.
What doesn't work is to recognize the FROM target from the form.
Hard coded (see below) it works fine.
Because I don't seem to be able to access the RECORD SOURCE programatically (in syntax that the query will accept), I put a text box [tbxTable] on the form that gets populated when the user changes the table to display. But I still can't figure out the correct syntax to recognize that field in the FROM clause
INSERT INTO [ME.frmProcessEditor].tbxNewTable ( PageKey, ShapeKey, ShapeText
SELECT tblP1.PageKey, tblP1.ShapeKey, tblP1.ShapeTex
FROM tblP
WHERE (((tblP1.PageKey)=forms.frmProcessEditor.tbxPageKey)
And ((tblP1.ShapeKey)=forms.frmProcessEditor.tbxShapeKey)
And ((tblP1.ShapeText)=forms.frmProcessEditor.tbxShapeText))
All suggestions appraciated
Situation: DB has multiple tables, all identical structures. Each is generated from a page in a Visio drawing. Access form displays all fields of a table and allow user to switch tables. One of the purposes of the form is to allow user to move a record to a different table. (Don't worry about duplicate records or keys here.) The code below will read the INSERT INTO target as a control on the form and read several textbox control values.
What doesn't work is to recognize the FROM target from the form.
Hard coded (see below) it works fine.
Because I don't seem to be able to access the RECORD SOURCE programatically (in syntax that the query will accept), I put a text box [tbxTable] on the form that gets populated when the user changes the table to display. But I still can't figure out the correct syntax to recognize that field in the FROM clause
INSERT INTO [ME.frmProcessEditor].tbxNewTable ( PageKey, ShapeKey, ShapeText
SELECT tblP1.PageKey, tblP1.ShapeKey, tblP1.ShapeTex
FROM tblP
WHERE (((tblP1.PageKey)=forms.frmProcessEditor.tbxPageKey)
And ((tblP1.ShapeKey)=forms.frmProcessEditor.tbxShapeKey)
And ((tblP1.ShapeText)=forms.frmProcessEditor.tbxShapeText))
All suggestions appraciated