Solved

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

Posted on 2013-01-21
5
427 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
  • 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 119

Accepted Solution

by:
Rey Obrero earned 500 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Today's users almost expect this to happen in all search boxes. After all, if their favourite search engine juggles with tens of thousand keywords while they type, and suggests matching phrases on the fly, why shouldn't they expect the same from you…
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
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.

747 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

9 Experts available now in Live!

Get 1:1 Help Now