Macro that adds 1 to table value

ckinninger

Registered User.
Local time
Today, 14:55
Joined
Mar 29, 2011
Messages
12
Hello,

I have a form with the access included macro to print selected record from form.

I want to add a step to the macro that will update a field in the form's query to +1.

Any help would be greatly appreciated.

Thanks
 
Are you talking about wanting to have the table's value updated permanently? Or just for display in the query? (also - it is best for printing to use REPORTS intead of forms as they are geared for printing whereas forms are much more limited in what you can do with them for printing).
 
Hello, Yes, add 1 to the table value permanently. The form uses a query of a couple tables so the value I want to update is right there. If you hit the print button it adds to the counter. For this, printing from the form seems fine (looks good). Thanks.
 
The simplest way is just to set up an update query and set the update part to
[fieldnamehere] + 1

and then call it from the same button using

DoCmd.OpenQuery "queryNameHere"
 

Ok I get the idea but I have two issues.


1.
How do I get a value from the current form into the query so that it only updates the table row that's open in the form? I know where it goes in the query (criteria). In the update query I add two columns:

Update
PrintCounter = PrintCounter+1

Where:
Criteria
InvoiceNumber = ??? Current Form InvoiceNumber ???


2
Is there going to be a simple way to suppress the update query warning that pops up?



I really appreciate the help.

CK
 
Ok I got the first one. I should be okay

Criteria for InvoiceNumber:
[Forms]![invoices-customer]![InvoiceNumber]

Still working on the update query warnings suppressions
 
Still working on the update query warnings suppressions

In your macro you can select the action SET WARNINGS and then in the argument you select NO and then the step after you have done everything put SET WARNINGS and YES.
 

I see it now. The set warnings action in macros was hidden. All good now. Turn off before query and on after.

I appreciate the help.
 

Users who are viewing this thread

Back
Top Bottom