Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 274
  • Last Modified:

Use VBA to Update All on Filtered Form

Hi,

Take a simple table with 5,000 records;
Product
Supplier
Area
Price

I have a continuous form which display these 4 fields.
I will use the standard "filter" facilities to restrict which records are displayed.

My Requirement: When I click on a button how do I set the [Price] field to zero for the records that are filtered.

I guess, the key thing here is how do I process my update on ONLY the filtered records.

0
Patrick O'Dea
Asked:
Patrick O'Dea
  • 3
1 Solution
 
Rey Obrero (Capricorn1)Commented:

with me.recordset
     .edit
     !price=0
     .update
end with
0
 
Rey Obrero (Capricorn1)Commented:
oops

with me.recordset
.movefirst
    do until .eof
     .edit
     !price=0
     .update
     .movenext
   loop
end with
0
 
Rey Obrero (Capricorn1)Commented:
you have to run the codes after applying your filter..
0
 
Patrick O'DeaAuthor Commented:
Thanks, Perfect!

An elegant solution.
I have never used recordsets before.
0

Featured Post

NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now