Yes, you can build the SQL dynamically. Where the problem comes in is that
you will have to allow for all of the possible combinations. Getting the
form's Filter value, as you mentioned, may be a good way to do this. The
Filter value will have the text needed for the Where statement, just without
the word Where.
Example:
strFilter = Replace(Me.Filter, Me.RecordSource & ".", "")
strSQL = "UPDATE Table1 SET Table1.Myfield = False WHERE LinkField = " &
Me.txtLinkField & " And " & strFilter & ";"
CurrentDb.Execute strSQL, dbFailOnError
Of course, you'll need to adjust for different data types by concatenating
in quotes, if needed. The reason for the Replace function is that the filter
lists the name of the record source (i.e. Query1.Field1 = 6) instead of just
the field. I haven't tried this, so this may or may not be a problem. I
suspect it wouldn't matter, but if it does, you can use the Replace function
to remove it.
--
Wayne Morgan
MS Access MVP
"GSteven" <st***@s1f-w1yr5cycl5r.com> wrote in message
news:d7***********@news3.infoave.net...
Wayne,
I appreciate your reply. But your answer leads to yet another question.
The idea here is for the EU to be able to filter the customer table (using
the filter by selection/exclusion toolbar) in order to choose who to
schedule for service. I can make the query do what you suggested with hard
code but how can I build the WHERE clause dynamically?
btw - I'm running Access 2000, have considerable SQL experience but am
just learning Access and VB.
Thanks again,
Steve
************************************************** ************************
"Wayne Morgan" <co***************************@hotmail.com> wrote in
message news:p7****************@newssvr12.news.prodigy.com ... You will need to apply the filter constraints in the Where clause of your
Update query to limit that query to only updating the records that match
the filter. For example, if you've filter the form to only show you
records where "Field1 = 2", then in the update query you would need
"WHERE Field1 = 2". You will also need to limit the update query to the
current value of the Master/Child link fields since this will also be
limiting the subform's recordset. You would add this in using an AND
statement in the Where clause.
--
Wayne Morgan
MS Access MVP
"GSteven" <st***@s1f-w1yr5cycl5r.com> wrote in message
news:d7***********@news3.infoave.net... (as formerly posted to microsoft.public.access.forms with no result)
I've created a continuous form which is based on a straightforward table
(ex - customers - 100 records). On the form there is a checkbox with a
control source named "MARK" (boolean) from customer table. I can check
and
uncheck individual records fine. Then I created 2 command buttons named
"Select All" and "Deselect All". The Onclick property of these buttons
runs
code which calls an update query. All works as expected except that I
wanted
to be able to select or deselect a filtered view of the records.
When I apply a filter and select all, ALL records are selected instead
of
just the records as viewed in the filtered set.
Anyone know of a way to improve upon this?
tia
Steve