Solved

Open Form - Filter Field - Update Another Field in Table

Posted on 2016-09-30
2
20 Views
Last Modified: 2016-09-30
Hi,

OnClick I'd like to open a form, filter by a field, and with ONLY the filtered records I'd like to update a Yes/No field in a table.

I've done the easiest bit, but also I'd like to update a field called 'SelectedPrint' in my 'Contacts' table with 'Yes' for every record filtered 'KI1100'

DoCmd.OpenForm "InvoiceEmail"
DoCmd.ApplyFilter , "Account = 'KI1100'"

Open in new window


Can anyone help?

Thanks,
0
Comment
Question by:Jack Marley
2 Comments
 

Accepted Solution

by:
Jack Marley earned 0 total points
ID: 41823601
Solved it myself, don't know if this is the best method but it works!

DoCmd.SetWarnings False
SQLtext = "update Contracts set SelectedPrint= Yes where Account='KI1100'"
DoCmd.RunSQL SQLtext
DoCmd.SetWarnings True

Open in new window

0
 
LVL 34

Expert Comment

by:PatHartman
ID: 41823615
Most times you don't want a hard-coded value so here is a better example:

SQLtext = "update Contracts set SelectedPrint= 'Yes' where Account= '" & Me.txtAccount & "'"

Or, if SelectedPrint is a Yes/No data type then:

SQLtext = "update Contracts set SelectedPrint= True where Account= '" & Me.txtAccount & "'"
1

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Regardless of which version on MS Access you are using, one of the harder data-entry forms to create is one where most data from previous entries needs to be appended to new records, especially when there are numerous fields and records involved.  W…
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now