473,320 Members | 1,699 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

VBA Question

A97, NT4.

I've inherited a database from a rather talented software developer and
some of his code scares me ;-)

One of the things I'm trying to understand is his custom "filter by form"
utility.

When the form is loaded, "acCmdFilterByForm" is executed.

Below is the code from the "On Apply Filter" event of the form. Could
someone please tell me how "ApplyType" (one of the arguments) gets a value
of 1? "ApplyType" isn't referenced anywhere else except for in this code
and no arguments are passed when the form is called.

Many thanks,
Keith.

Private Sub Form_ApplyFilter(Cancel As Integer, ApplyType As Integer)
' Only apply filter if explicity requested from the Shortcut Menu
'
' We have to update the caller from here because we can't
' Filter by Form from a dialog
On Error GoTo errTrap

' Procedure name
Const cProcedure = "Form_ApplyFilter"

Dim frm As Form

If libIsFormLoaded(gcFrmProgress) Then
Set frm = Forms(gcFrmProgress)

If ApplyType = acApplyFilter And libIsFormLoaded(gcFrmProgress)
Then
frm!cmdAdvanced.SetFocus
frm!cboFilter.Enabled = False
frm!txtFilterDescription.Enabled = False
frm!txtFilterDescription.Locked = False
frm!shpFilter.Visible = False
frm!cboItem.RowSource = "SELECT ItemID, Description, Area,
Type, SeatOwner, Status, Deleted FROM " & Me.RecordSource _
& " WHERE " & Me.Filter & " ORDER BY ItemID"
' frm!cboItem.RowSource = "SELECT DISTINCT tblItem.ItemID,
tblItem.Description, tblItem.Area, tblItem.Type, tblItem.SeatOwner,
tblItem.Status, tblItem.Deleted FROM (tblItem INNER JOIN tblTask ON
tblItem.ItemID = tblTask.ItemID) INNER JOIN qfrmProgress ON tblItem.ItemID
= qfrmProgress.ItemID WHERE (((tblTask.OpCode) Not Like 'B*') AND
((tblTask.Progress)<1) AND ((tblTask.Applicable)=True) AND " & Me.Filter &
") ORDER BY ItemID"
frm!cboItem = frm!cboItem.ItemData(0)
frm!sfrProgress.LinkMasterFields = "cboItem"
frm!sfrProgress.LinkChildFields = "ItemID"
frm.RefreshItemDetails
frm.ControlState
' frm.Requery
frm.Filtered = True
ElseIf ApplyType = acCloseFilterWindow Then
frm.Filtered = False
End If
Set frm = Nothing
End If

' Save filter (users do not have write access)
gFilter = Me.Filter

' Close form
DoCmd.Close acForm, Me.Name
Exit Sub
Nov 13 '05 #1
4 5001
Keith <ke*********@AwayWithYerCrap.com> wrote:
A97, NT4.

I've inherited a database from a rather talented software developer and
some of his code scares me ;-)

One of the things I'm trying to understand is his custom "filter by form"
utility.

When the form is loaded, "acCmdFilterByForm" is executed.

Below is the code from the "On Apply Filter" event of the form. Could
someone please tell me how "ApplyType" (one of the arguments) gets a value
of 1? "ApplyType" isn't referenced anywhere else except for in this code
and no arguments are passed when the form is called.

Many thanks,
Keith.

Private Sub Form_ApplyFilter(Cancel As Integer, ApplyType As Integer)
' Only apply filter if explicity requested from the Shortcut Menu
'

[...]

The value of ApplyType is filled in by the caller of this event, which
occurs e.g. if the user selects "Apply Filter" on the menu, but also
if the user selects "remove filter/sort" on the menu.
Possible values are: acShowAllRecords = 0 and acApplyFilter = 1

HTH
Matthias Kläy
--
www.kcc.ch

----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----
Nov 13 '05 #2
Matthias Klaey <mp**@hotmail.com> wrote:
The value of ApplyType is filled in by the caller of this event, which
occurs e.g. if the user selects "Apply Filter" on the menu, but also
if the user selects "remove filter/sort" on the menu.
Possible values are: acShowAllRecords = 0 and acApplyFilter = 1

HTH
Matthias Kläy


Hi Matthias and many thanks for your response. I understand now - I
originally thought that my predecessor had declared an ApplyType variable
himself, I now realise that it is a default argument.

Thaks again.
Keith.
Nov 13 '05 #3
Keith wrote:
Matthias Klaey <mp**@hotmail.com> wrote:

The value of ApplyType is filled in by the caller of this event, which
occurs e.g. if the user selects "Apply Filter" on the menu, but also
if the user selects "remove filter/sort" on the menu.
Possible values are: acShowAllRecords = 0 and acApplyFilter = 1

HTH
Matthias Kläy

Hi Matthias and many thanks for your response. I understand now - I
originally thought that my predecessor had declared an ApplyType variable
himself, I now realise that it is a default argument.


If like me (and many others here) the developer used naming conventions
for his/her variables, you can tell the built in Access events by the
fact that they don't have naming conventions applied on the parameters :-)

--
This sig left intentionally blank
Nov 13 '05 #4
Trevor Best <no****@besty.org.uk> wrote:
Hi Matthias and many thanks for your response. I understand now - I
originally thought that my predecessor had declared an ApplyType
variable himself, I now realise that it is a default argument.


If like me (and many others here) the developer used naming conventions
for his/her variables, you can tell the built in Access events by the
fact that they don't have naming conventions applied on the parameters
:-)


Yes I should have realised really. Like I say some of that code scares me
(he was a software engineer, I'm not) and there's lots of it for me to wade
though and understand :o)
Nov 13 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Mohammed Mazid | last post by:
Can anyone please help me on how to move to the next and previous question? Here is a snippet of my code: Private Sub cmdNext_Click() End Sub Private Sub cmdPrevious_Click() showrecord
3
by: Stevey | last post by:
I have the following XML file... <?xml version="1.0"?> <animals> <animal> <name>Tiger</name> <questions> <question index="0">true</question> <question index="1">true</question> </questions>
7
by: nospam | last post by:
Ok, 3rd or is it the 4th time I have asked this question on Partial Types, so, since it seems to me that Partial Types is still in the design or development stages at Microsoft, I am going to ask...
3
by: Ekqvist Marko | last post by:
Hi, I have one Access database table including questions and answers. Now I need to give answer id automatically to questionID column. But I don't know how it is best (fastest) to do? table...
10
by: glenn | last post by:
I am use to programming in php and the way session and post vars are past from fields on one page through to the post page automatically where I can get to their values easily to write to a...
10
by: Rider | last post by:
Hi, simple(?) question about asp.net configuration.. I've installed ASP.NET 2.0 QuickStart Sample successfully. But, When I'm first start application the follow message shown. ========= Server...
53
by: Jeff | last post by:
In the function below, can size ever be 0 (zero)? char *clc_strdup(const char * CLC_RESTRICT s) { size_t size; char *p; clc_assert_not_null(clc_strdup, s); size = strlen(s) + 1;
56
by: spibou | last post by:
In the statement "a *= expression" is expression assumed to be parenthesized ? For example if I write "a *= b+c" is this the same as "a = a * (b+c)" or "a = a * b+c" ?
2
by: Allan Ebdrup | last post by:
Hi, I'm trying to render a Matrix question in my ASP.Net 2.0 page, A matrix question is a question where you have several options that can all be rated according to several possible ratings (from...
3
by: Zhang Weiwu | last post by:
Hello! I wrote this: ..required-question p:after { content: "*"; } Corresponding HTML: <div class="required-question"><p>Question Text</p><input /></div> <div...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.