My Assistant
![]() ![]() |
|
|
Nov 9 2005, 08:15 PM
Post
#1
|
|
|
UtterAccess Enthusiast Posts: 97 From: Southern Cali |
OK, I have an old application I have to maintain -- it has forms and reports.
One of the reports (a whole bunch actually) has a function called "SetTotalClaimed", which sets one of the fields in the report to a certain value. The thing is, I can't figure out how it gets called. The "Report_Open" event handler does not call it. It must be wired up to an event, but I can't figure out which one. The property page for the report says there is just one event -- the No Data event. I have to create another report with similar functionality, so I really need to understand this. How can I find out how this function is called? Thanks, Cynthia |
|
|
|
Nov 9 2005, 08:19 PM
Post
#2
|
|
|
Retired Moderator Posts: 10,493 From: Lexington/Louisville KY USA |
It could be the Control Source for an unbound control.
=SetTotalClaimed It's it triggered by an event, it should show in the VBA window, unless it's used on the Event Tab like: =SetTotalClaimed HTH Noah |
|
|
|
Nov 9 2005, 08:27 PM
Post
#3
|
|
|
UtterAccess Enthusiast Posts: 97 From: Southern Cali |
Well ...
(1) If it's defined as a Control Source, then the control is not unbound, is it? (I can't find a control that has this as its Control Source .. is there any place where they are listed?) (2) What do you mean by the VBA window? (3) What do you mean by the Event Tab? Otherwise .. thanks! Cynthia |
|
|
|
Nov 9 2005, 08:39 PM
Post
#4
|
|
|
Utter A-fishin'-ado Posts: 17,723 From: Cincinnati, Ohio, USA . . . ><((((°> |
Can you post the DB? You can delete all personal data in the tables. Sometimes seeing it is the easiest way.
|
|
|
|
Nov 9 2005, 10:24 PM
Post
#5
|
|
|
UtterAccess Enthusiast Posts: 97 From: Southern Cali |
Hmmm, not really! The database is about 30MB, and there is a file of linked tables that is about 132MB. I mean, this is a large application!
I am just so confused as to how a function like this gets executed. Does anyone know the "lifecycle" of the generation of a report? Is it perhaps true that if there is a function in the code-behind, it will automatically get executed when the report is generated? That does not make sense to me, but I can't think of anything else right now. |
|
|
|
Nov 9 2005, 10:33 PM
Post
#6
|
|
|
Retired Moderator Posts: 10,493 From: Lexington/Louisville KY USA |
1) If a function is in the Control Source of a control, then the control IS unbound.
2) The VBA window is the window containing all the code for a given form, report or module. 3) The Event Tab is one of the tabs on the Property box. Right click anywhere in the report, and the Left Click Properties at the bottom of the menu that opens. Each control on a report, the report itself and each section of the report will have its own set or Properties. Noah |
|
|
|
Nov 9 2005, 10:36 PM
Post
#7
|
|
|
Utter A-fishin'-ado Posts: 17,723 From: Cincinnati, Ohio, USA . . . ><((((°> |
There are many, many events that fire off code in the Code-Behind of a report. OnFormat, OnOpen, OnPrint, etc, etc....
More than likely this is where the function is being called from. |
|
|
|
Nov 10 2005, 01:28 AM
Post
#8
|
|
|
UtterAccess Enthusiast Posts: 97 From: Southern Cali |
OK, but how do I find what event handlers (if any) are connected to each event? Is there a list somewhere?
When I look on the events tab of the property window (thank you Noah) there seems to be only one event handler -- for the NoData event. The SetTotalClaimed function does not SEEM to be wired up to an event. Cynthia |
|
|
|
Nov 10 2005, 02:35 AM
Post
#9
|
|
|
UtterAccess VIP Posts: 5,200 From: Denver, Colorado [USA] |
Open up your report in design view. Click VIEW/CODE from the menus to get to the full VBA code behind the report. Is the function called anywhere in there?
The other place it could be called, as mentioned, is in the CONTROLSOURCE property (not an event) for the textbox that displays the result. It may also be code in a GLOBAL code module, which may be referenced from your report. Open up the MODULES in your application and check there. If you have the VBE open, you can do an EDIT/FIND and specify to search in the CURRENT PROJECT for your function name. |
|
|
|
Nov 10 2005, 06:04 AM
Post
#10
|
|
|
UtterAccess VIP Posts: 18,396 From: Oklahoma City, Oklahoma |
I could also be called from within the record source (query) of the report. It is possible to call the function from within the SQL.
Hope this helps... |
|
|
|
Nov 10 2005, 01:57 PM
Post
#11
|
|
|
UtterAccess Enthusiast Posts: 97 From: Southern Cali |
Here is the query that is the source of the report:
CODE SELECT DISTINCT Sites.SiteName, Sites.KindegartenEntrants, Sites.OutOfStateXfers, Mandates.ProgramID, Mandates.ProgramName, Mandates.Chapter, Mandates.StatuteYear, Mandates.Appropriations, Mandates.EducCodes, Mandates.LongProgramName, Mandates.DetailFormName, Mandates.SummaryFormName, Mandates.ClaimFormName, Districts.*, DistrictInfo.Abbreviation, DistrictInfo.IndirectRate, DistrictInfo.SiteSize, DistrictInfo.[#Truants], DistrictInfo.[#Screened], DistrictInfo.[#ReScreened], DistrictInfo.Medical, tblUnitRates.Factor, tblUnitRates.YearID, tblClaims.EstimatedClaim, tblClaims.ReimbursementClaim FROM ( ( Districts INNER JOIN DistrictInfo ON Districts.DistrictID = DistrictInfo.DistrictID ) INNER JOIN Sites ON Districts.DistrictID = Sites.DistrictID ) INNER JOIN ( ( tblUnitRates INNER JOIN tblClaims ON (tblClaims.MandateID = tblUnitRates.ProgramID) AND (tblUnitRates.YearID = tblClaims.ProgramYearID) ) INNER JOIN Mandates ON tblClaims.MandateID = Mandates.ProgramID ) ON Districts.DistrictID = tblClaims.DistrictID WHERE ( ( (Mandates.ProgramID)=[forms]![PrintMenuFRM]![chooseProgramID] ) AND ( (Districts.DistrictID)=[forms]![PrintMenuFRM]![chooseDistrictBox] ) AND ( (DistrictInfo.YearID)=[forms]![PrintMenuFRM]![chooseProgramYearID] ) AND ( (Sites.DistrictID)=[forms]![PrintMenuFRM]![chooseDistrictBox] ) AND ( (tblClaims.ProgramYearID)=[forms]![PrintMenuFRM]![chooseProgramYearID] ) ) ORDER BY Sites.SiteName; and here is the entire visual basic code for this report: CODE Option Compare Database Option Explicit Public Function SetTotalClaimed() On Error GoTo HandleErrors Me![13] = dblTotalClaimed + dblTotalClaimed2 'frm![TotalClaimed] = dblTotalClaimed Exit Function HandleErrors: MsgBox "Error was encountered... Proceeding with errors." & vbCrLf & vbCrLf & "Please note the District and Program being printed for tech support.", vbInformation Resume Next End Function Private Sub Report_NoData(Cancel As Integer) If ContinueReportGeneration(Me.Name) = True Then Cancel = False Else Cancel = True End If End Sub Private Sub Report_Open(Cancel As Integer) DoCmd.Maximize End Sub I did do a search on the "SetTotalClaimed" function, and I can't find anywhere in the code that it is called, although it appears in the code-behind of several reports. Also, none of the fields in the report have "SetTotalClaimed" as the Control Source. (Anyway, even though it's a function, it acts more like a Sub since nothing is returned.) |
|
|
|
Nov 10 2005, 05:50 PM
Post
#12
|
|
|
UtterAccess VIP Posts: 5,200 From: Denver, Colorado [USA] |
You indicated this was an old application.
Are you sure this function is ever being called? Perhaps it is just unused code, that served a purpose at one time but no longer. Is there a control named [13] on your report? Does it get set as this function says it will? What is it's controlsource? Maybe the original author used to do this calculation via this "function", but now is doing it straight in the controlsource of the control, and this code is just "abandoned." You could test if this code ever runs by putting a "debug" line in there: CODE Public Function SetTotalClaimed() On Error GoTo HandleErrors MsgBox "THE FUNCTION WAS CALLED." Me![13] = dblTotalClaimed + dblTotalClaimed2 'frm![TotalClaimed] = dblTotalClaimed Exit Function HandleErrors: MsgBox "Error was encountered... Proceeding with errors." & vbCrLf & vbCrLf & "Please note the District and Program being printed for tech support.", vbInformation Resume Next End Function If you never see that MessageBox pop up, the code is likely not used. Make a copy of your report and delete the "function" from it. If the report still works and all the totals are correct, the function is abandoned and not needed. |
|
|
|
Nov 10 2005, 07:18 PM
Post
#13
|
|
|
UtterAccess Enthusiast Posts: 97 From: Southern Cali |
No .. there is a [13] control, and it IS being set by this function. I have put a breakpoint in there. There is no value for the Control Source of this text box.
I just can't figure out WHY it is called. I can't find a call to it. Now, by stepping through with the debugger, I am discovering that several functions in a module called "Report Code" are being executed. I can't find any calls to them. I don't understand it. Is there some way an application could be wired up so that ALL reports call some function(s) in a module ... is there a way of doing that, and if so, is there a way of looking at what functions are called in this way? |
|
|
|
Nov 10 2005, 07:38 PM
Post
#14
|
|
|
UtterAccess VIP Posts: 5,200 From: Denver, Colorado [USA] |
Since we're all kind of shooting blind here, any chance you could zip up and post your MDB?
|
|
|
|
![]() ![]() |
|
Go to Top · Lo-Fi Version | Time is now: 23rd May 2013 - 02:21 PM |