Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Update fields in filtered view (filter based on two tables)

Posted on 2013-01-21
5
Medium Priority
?
449 Views
Last Modified: 2013-01-21
Using Access 2010,  continuous form.  This form has read-write access to Table1 but only reads (displays fields) from Table2

I have enabled the user to dynamically filter the form with criteria from both tables. This works fine for a form filter.  Everything is great but.....

I have a field in Table1 called [Tag].   I would like the user to create a filtered result of all the records.  I've got that part done.  Next,  I would like to enable the user to click a button and cause all the records in the current view to have the [Tag] field set to "y".

My form filter looks like this.     Me.Filter = "[Transaction Type] = 1 and [Shape] = 'Round'"    

I tried the following command to update Table1.[Tag]

Currentdb.execute "Update Table1 Set Table1 & [Tag] = 'y' where [Transaction Type] = 1 and [Shape] = 'Round'"

As far as I can tell, this command fails because it refers to a field in Table2.
Solution?
0
Comment
Question by:peispud
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 29

Expert Comment

by:IrogSinta
ID: 38801078
Try this:
Currentdb.execute ("Update Table1 Set [Tag] = 'y' where [Transaction Type] = 1 and [Shape] = 'Round'"), dbFailOnError

Open in new window

0
 
LVL 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 2000 total points
ID: 38801100
you update the filtered recordsets..after you apply the filter

with me.recordsetclone
     do until .eof
     .movefirst
        .edit
        !Tag="Y"
        .update
     .movenext
loop
end with


or just use

with me.recordset
     do until .eof
     .movefirst
        .edit
        !Tag="Y"
        .update
     .movenext
loop
end with
0
 

Author Comment

by:peispud
ID: 38801141
I changed "table1" and [Tag]  and tried to follow your example.  The first one fails.  The second one works.  The difference between the two is  .... and [Shape] = 'Round'.

That field refers to table2  


CurrentDb.Execute ("Update [tblTransaction] Set [Invoice Tag] = 'y' where [Transaction Type] = 1 and [Shape] = 'Round'"), dbFailOnError

CurrentDb.Execute ("Update [tblTransaction] Set [Invoice Tag] = 'y' where [Transaction Type] = 1"), dbFailOnError
0
 
LVL 29

Expert Comment

by:IrogSinta
ID: 38801196
Are you using a Lookup field for [Shape] in the table?
0
 

Author Comment

by:peispud
ID: 38801243
Yes.. [Shape] is a Lookup field.

I've tried Capricorn1's solution.

It works fine. Thank you both for your help.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

722 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