Explain VBA code

The following VBA code is a function called from a form that allows a user to "Reset", "Preview", "Print" or "Close". Assuming the reset and close affect the form and the Preview and Print affect a report.The user clicks one of the command buttons on the form which triggers the function. I am unsure exactly what it does.  The line "Application.Run strFunctName, strParam"  appears to do something. Can someone explain what is going on here. Thank you.

Function GenRptButtons(strParam As String) As Variant
  ' Comments   :
  ' Parameters :
  ' Returns    :
  ' Created    : 6/24/1998 11:25:19 AM rlk
  ' Modified   :
  '
  ' --------------------------------------------------------
  On Error GoTo GenRptButtons_ERR
 
  Dim strFunctName As String
 
  DoCmd.Hourglass True
 
  strFunctName = Screen.ActiveForm.Name
 
  Application.Run strFunctName, strParam
 
GenRptButtons_Exit:
  DoCmd.Hourglass False
 
  Exit Function

GenRptButtons_ERR:
  MsgBox "The following error occurred in GenRptButtons" & Chr(13) _
    & "Error # " & Str(Err.Number) & " was generated by " _
    & Err.Source & Chr(13) & Err.Description

  Resume GenRptButtons_Exit

End Function
StampITAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Rey Obrero (Capricorn1)Commented:
<The user clicks one of the command buttons on the form which triggers the function>

First, you have to take note of the codes that are on the CLICK EVENT of each command button.
Those codes will tell you the parameters passed to the functions.

copy the codes and paste them here so we can explain what it intends to do.
MacroShadowCommented:
Application.Run calls a sub\function with the name of the current form passing a string parameter which you say can by "Reset", "Preview", "Print" or "Close".
als315Commented:
It is some approach to have form independent code in buttons.
Application.Run  strFunctName, strParam
is call of sub with name strFunctName
in previous line it is assigned to Form's name:   strFunctName = Screen.ActiveForm.Name
strParam is parameter of sub.
There should be public subs (in module) with names equal to forms names,
in button code should be like:
Private Sub Button94_Click()
     GenRptButtons ("Test")
End Sub
PatHartmanCommented:
Screen.ActiveForm.Name - is just what it says - the name of the active form.
 Application.Run  - runs the procedure named by the first argument so look for a procedure with the name of some form.  The second argument is whatever was passed to the sub in its arguments.

To see these names, put a stop on the Application.Run line.  Then look at the contents of both variables.  Either by hovering with the mouse or by specifically printing them in the debug window.
strFunctName - will be the name of the procedure being executed
strParam  - will be the value passed to that procedure

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
StampITAuthor Commented:
Once I could see the name of the procedure being executed it became clear as to what was happening. Thanks.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.