Re: Tricky Visual Basic Code help...



I am trying to do something very similar actually, but I'm a complete
beginner to VBA and don't know exactly where to begin.

I have an access file that has two linked tables, which each link to
separate SQL databases using separate ODBC connections.

I have a form that has a view of table1 and a set of buttons for
manipulating the data in database1.

The tough part is the button that's going to go on this form which puts
moves the current record into a new record in table2 (database2).

Through extensive testing we found it's impossible to simply do this
with the built-in form builder tools - it only works if the tables are
local and not linked. However, queries which manipulate data between
linked tables work fine, which is what gives us the notion we can do
this with a little VBA code and a couple custom queries.

So far, the plan is the make the button do this:
1) Set a "pushFlag" column in the record in table1 to a specific
identifying value ("1" for now)
2) Runs an insert query to insert "all records with pushFlag = 1"
into table2. (this would create a copy of the record)
3) Sets the "status" field in the new record in table2 to a specific
value. ("done" for now)
4) Runs a delete query that first checks for duplicates (records that
exist in both the table1 and table2) and if a duplicate is found the
table1 record is removed. If a duplicate is not found, then the insert
must have failed for some reason. Instead of deleting the record the
user is notified that the insert failed, probably because of mal-formed
data in the record.

Does this sound remotely feasible? Would anyone be willing to help me
get this to work?



HockeyBeast wrote:
I am trying to import data from a record on one table to another through
several forms. First, I have a query that grabs a set of records from the
source table based on a criteria the user enters and displays in a tabular
form. Then, I have a command button in the header of the form that opens a
second form, call it the submit form, with blank fields to allow the user to
enter data and not affect the source table. The entered data is stored to
records on the submit table.

What I am trying to accomplish is to import some fields of data from the
source table to the submit table based on the record the user clicks on in
the first form. Know the submit form opens with doCmd.OpenForm and there are
several options with this funciton. Is there code that can accomplish the
task?

.