dbTalk Databases Forums  

Macro filter with IN clause

comp.databases.ms-access comp.databases.ms-access


Discuss Macro filter with IN clause in the comp.databases.ms-access forum.



Reply
 
Thread Tools Display Modes
  #11  
Old   
Bill E. Hollywood, FL
 
Posts: n/a

Default Re: Macro filter with IN clause - 09-06-2011 , 09:55 AM






Quote:
Not true anymore, but I guess it would be a hard sell to get your friend to
upgrade.

However, I don't like this approach and I'm
trying to keep this as simple as possible so that my friend is not
overwhelmed--thus the request to not involve Visual Basic in the
solution.

I'm afraid I'm out of suggestions. Hopefully someone else will chime in.
Are you saying that MS Access now has triggers?

Reply With Quote
  #12  
Old   
Bob Barrows
 
Posts: n/a

Default Re: Macro filter with IN clause - 09-06-2011 , 10:39 AM






Bill E. Hollywood, FL wrote:
Quote:
Not true anymore, but I guess it would be a hard sell to get your
friend to upgrade.

However, I don't like this approach and I'm
trying to keep this as simple as possible so that my friend is not
overwhelmed--thus the request to not involve Visual Basic in the
solution.

I'm afraid I'm out of suggestions. Hopefully someone else will chime
in.

Are you saying that MS Access now has triggers?
Yes, I was surprised by this as well. It seems they were introduced in
A2010. They're called "data macros" I think.

Reply With Quote
  #13  
Old   
Bill E. Hollywood, FL
 
Posts: n/a

Default Re: Macro filter with IN clause - 09-07-2011 , 03:29 AM



Quote:
Yes, I was surprised by this as well. It seems they were introduced in
A2010. They're called "data macros" I think.
I took a look and this functionality is impressive. I'll have to do
some experiments. I also noticed that they finally cleaned up the
problem with derived tables inside queries. For example, the query

SELECT ID Name
FROM (SELECT CustomerID AS ID, CustomerName AS Name FROM Customers) Q

would always be changed by Access to read

SELECT ID Name
FROM [SELECT CustomerID AS ID, CustomerName AS Name FROM Customers]. Q

and this []. notation would cause problems. Thank goodness it's
fixed.

Reply With Quote
  #14  
Old   
Bill E. Hollywood, FL
 
Posts: n/a

Default Re: Macro filter with IN clause - 09-12-2011 , 06:08 AM



Just to end this thread, I eventually decided to create a function in
Visual Basic that I could call from a macro that would reset the
recordsource of a form or subform contained in a form. The code is
below. In this way I no longer need to do "fancy" filtering. Also,
this is the way I would naturally do things when writing Visual Basic,
so why not do it the same way with macros?

Function SetFormRecordsource(FormName As String, SubformName As
String, Query As String)
'Change the recordsource for a form or subform
On Error GoTo Trapper
Dim frm As Form

If SubformName = "" Then
Set frm = Forms(FormName)
Else
Set frm = Forms(FormName).Controls(SubformName).Form
End If

If frm.RecordSource <> Query Then
frm.RecordSource = Query
'frm.Requery
Else
frm.Requery
End If
Set frm = Nothing
Exit Function
Trapper:
'MsgBox Err.Description
Set frm = Nothing
Exit Function
End Function

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.