Updating table with Command Button

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I would like to know if and how I can update a table with a command button.
Due to server problems. I have Database where to two users have a copy of
the db. The main Db is update daily by updating each field with the
following query:

Main Table outer join to tblcpy MainTrkg

field: fieldnm1
Table: tblMainTrkg
Update to: Nz([tblMainTrkg].[fieldnm1],[tblcpyMainTrkg].[fieldnm1])
Criteria: Is Null

field: fieldnm1
Table: tblcopyMainTrkg
Update to: Nz([tblMainTrkg].[fieldnm1],[tblMainTrkg].[fieldnm1])
Criteria: Is Not Null

I run this query for each field that needs updating. I would like to
automate. I would like to know how to go about this. There are ten fields
that need to be updated. Do I make a query for each field? Can I run all
queries with a command button? Can someone please guide me? I would
appreciate any help with this. Thank you in advance for any help.
 
yes, you can automate it with a macro or VBA code. since it appears that
each field to be updated has its' own criteria, then i believe you'll need a
separate Update query for each field - unless you're wanting to update only
those records where *all* the criteria apply to each record. you can run one
or more queries easily enough in a macro, by starting with a SetWarnings
action, setting to False, then an OpenQuery action for each Update query you
want to run, and finally another SetWarnings action, setting to True.

hth
 
Back
Top