saving records from a form to a table not bound to the form

  • Thread starter Thread starter bpolite
  • Start date Start date
B

bpolite

I have created a form from which users will select items. These items are
located on a table call tblImage. I then am trying to have the selected items
recorded on a table other than tblImage so that the items selected will be
recorded without changing the records on the table bound to the form
(tblImage). I would appreciate it very much if someone could instruct me on
how to accomplish this task.

Thanks in Advance
 
Hi

Add code to the button or control on your form that users click to make
their selection. The code will need to create a SQL Insert Into statement
using the values from your form. You then execute the sql statement to add
the data into your other table.

Mark
 
Thank you Mark,
I believe that you have pointed me in the right direction. However, I need a
little further help. I have researched the sql insert statement but am not
sure how to write the code to my control. The issue is that I am not sure how
to write the portion for the value because they will not be the same for each
record. How do I write it to insert the value no matter what the value for
the field may be? Do I use a wild card symbol? I am using a command button as
my control. I really appreciate your help.

Thanks Again
 
Let's say you have a cmd button on every row (continuous forms) or maybe a
check box.

In the Checkbox AfterUpdate event or cmd Click event you create your
procedure which creates a sql insert statement using values on the current
row and then executes that statement.

To get the syntatx of the insert statement right, try creating an example in
the query window and then grabbing the sql.

it might look like this;

INSERT INTO tblContacts2 SELECT FROM tblContacts WHERE
(((tblContacts.[Contact ID])=999));

In code you need to substitute 999 with the ID column of your current row

strSQL = "INSERT INTO tblContracts SELECT FROM tblContacts WHERE
(((tblContacts.[Contact ID])=" & me.ID & "));" 'where me.ID is the name
of your ID field and is numeric.

Your 2 tables also need the same structure

Then execute using

CurrentDB().Execute strSQL

HTH
Mark
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top