How to run an update query on the current record (in a form) only?

G

Guest

I have a command button in a form that runs a macro that runs several update
queries, and I can't figure out how (or where) to limit the update query to
the record I'm currently in.

Do I set it as a condition in the query? or the macro? and what syntax do I
use?
 
G

Guest

Set Criteria in query to the key value in the form field.

=[Forms]![YourFormName].[FieldName]
 
G

Guest

Karl: Thanks for your response, but the solution you suggest is the approach
I can't get to work.

I've got a printing database.
The form name is: fPR (form: print)
Since many of the jobs are repeat, this form (table) contains the info that
never changes, like the title of the job, the department that it comes from,
the format (newsletter, or booklet, or whatever), and a couple of other
things. So once a job is logged in for the first time, none of that has to be
repeated the next time the job gets printed.

There's a subform: fprJB (form: print job)
This form (table) contains all the specifics related to printing the job.

There are several subforms associated with fprJB: fjbFD (form: job fold),
fjbPP (paper), etc. These are all the various processes that can be applied
to a print job during production. Sometimes a job is folded, sometimes not.
If it is, there's an associated entry made in the jbFD table by way of the
fjbFD subform, etc.

My update query inserts the current setup and perUnit dollar amounts into
the underlying table for folding, so we can calculate costs and charges.
There's an update query for each process.

I don't want to run the update query on the entire database because I don't
want jobs done a year ago (with different setup and perUnit amounts) to be
overwritten with current setup and perUnit amounts.

So I set up the query like you suggest and click my "Update" button (which
is on the 1st-level subform: fprJB), and I get the "Enter Paramater" dialog
box, basically asking "ok, so what form are you in?" If I type in the number,
the update query runs just fine, and only the record I'm in gets updated,
which is what I want. But obviously, nothing happens if I dismiss this dialog
box.

So I'm not sure what I'm doing wrong.


KARL DEWEY said:
Set Criteria in query to the key value in the form field.

=[Forms]![YourFormName].[FieldName]

pete said:
I have a command button in a form that runs a macro that runs several update
queries, and I can't figure out how (or where) to limit the update query to
the record I'm currently in.

Do I set it as a condition in the query? or the macro? and what syntax do I
use?
 

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

Top