Anna:
Lets take it piece by piece:
Select Case framSelectList
Case 1
txtSelectList = ""
Case 2
txtSelectList = "[CACN] = 'A'"
Case 3
txtSelectList = "[CACN] = 'N'"
Case Else
MsgBox "Please select a list", , "Select a List"
framSelectList.SetFocus
End Select
In what event procedure is this code located? It examines the option group
framSelectlist and sets the value of a (hidden?) text box, txtSelectList, to
a zero length string, "[CACN] = 'A'" or "[CACN] = 'N'" depending on which
option button is selected. It also includes a Case Else statement which I'd
imagine is if no option is selected as it prompts the user to make a
selection. The string expressions are not values for a parameter in the
normal way. If they were the value of the text box would be set to just A or
N and the CACN column in a query would reference the text box. It looks more
like a string expression to be concatenated into an SQL statement, which
might be done within the code in the procedures in the ReportUtilities module
(see below).
This is in the command_click button
Select Case framDeletes
Case 1
txtDeletes = ""
Case 2
txtDeletes = "[Delete] = 0"
framDeletes.SetFocus
End Select
DoCmd.SetWarnings False
Me.Form.Refresh
Call ReportUtilities.GetParishioners
Call ReportUtilities.DeleteContribTmpTbl
Call ReportUtilities.GetCurrentContribs
'DoCmd.OpenQuery "RosterContributions qry", acViewNormal, acEdit
DoCmd.SendObject acSendQuery, "RosterContributions qry", acFormatXLS, ,
, "Data Recording", "Company", , True
This appears to refer to another option group and to judge by the name of
the control sounds like it is for deleting records. It again sets the value
of a (hidden?) text box to a sting expression, and then calls some procedures
in a module called ReportUtilities, and finally uses the SendObject method to
send a query as an email attachment in XLS format. There is a line before
this to open the query, but this is commented out, so won't execute.
The first thing to do is have a look at the GetParishioners,
DeleteContribTmpTbl and GetCurrentContribs procures in the ReportUtilities
module to see what they do. My guess is that these probably make use of both
the text boxes whose values are set in the code in the form's class module.
To be honest it all looks rather messy. If the values in the text boxes are
being used by the procedures in the module then its not a very good approach.
Far better would be to pass the values as arguments to the procedures. I
think you should concentrate on what these routines are intended to do,
rather than trying to figure out how the previous developer tried to do it.
I'd suspect that once the purpose of the routines is understood a better way
of doing it can be produced.
One other thing I notice which makes my antennae twitch is that from its
name it sounds like the DeleteContribTmpTbl procedure might be deleting a
temporary table. Sometimes creating a temporary table makes sense, but my
experience has tended to be that its more commonly a device to overcome more
fundamental shortcomings in an application.
Ken Sheridan
Stafford, England