D
Dennis
Access 2003
I want to have the variable myString to equal the output of a function
(which is a string) called myFunction().
****************************************
The original function is next:
Public Function XYZ(stDatabase As String) As String
....
....
End Function
*****************************************
Therefore which format should I use?
myString = XYZ
- or -
myString = XYZ()
- or -
myString = XYZ(stDatabase As String)
Also, if I want "myString" available to a SubABC()
do I include (one of the above for example)?
Example 1
****************************
SubABC()
myString = XYZ()
End Sub
I want myString to pass into the Function faqChangePassword() below. But
Me!NewPassword is intended to be used only with a form click - I think in a
Class Module? Where as I believe that SubABC() needs to be in a General
Module
Thus, should I merge Function faqChangePassword() into the sub-routine as I
did below? Or leave it as a separate function? If so what type of Module?
Would it be better to use an Input box? to get NewPassword then pass it below?
I just do not know how to structure functions and sub-routines to work
properly.
Please any help?
Dennis
Example 2
****************************
SubABC()
myString = XYZ()
Call faqChangePassword(CurrentUser(), Me!NewPassword, _
myString)
Function faqChangePassword(ByVal strUser As String, ByVal_
strPwd As String, ByVal strOldPwd As String) As Integer
Dim ws As Workspace
Dim usr As User
On Error GoTo err_ChangePassword
Set ws = DBEngine.Workspaces(0)
Set usr = ws.Users(strUser)
usr.NewPassword strOldPwd, strPwd
err_ChangePassword:
If Err.Number = 3033 Then
MsgBox "You do not have permission to modify _
passwords. Please contact your system _
administrator."
End If
End Function
End Sub
I want to have the variable myString to equal the output of a function
(which is a string) called myFunction().
****************************************
The original function is next:
Public Function XYZ(stDatabase As String) As String
....
....
End Function
*****************************************
Therefore which format should I use?
myString = XYZ
- or -
myString = XYZ()
- or -
myString = XYZ(stDatabase As String)
Also, if I want "myString" available to a SubABC()
do I include (one of the above for example)?
Example 1
****************************
SubABC()
myString = XYZ()
End Sub
I want myString to pass into the Function faqChangePassword() below. But
Me!NewPassword is intended to be used only with a form click - I think in a
Class Module? Where as I believe that SubABC() needs to be in a General
Module
Thus, should I merge Function faqChangePassword() into the sub-routine as I
did below? Or leave it as a separate function? If so what type of Module?
Would it be better to use an Input box? to get NewPassword then pass it below?
I just do not know how to structure functions and sub-routines to work
properly.
Please any help?
Dennis
Example 2
****************************
SubABC()
myString = XYZ()
Call faqChangePassword(CurrentUser(), Me!NewPassword, _
myString)
Function faqChangePassword(ByVal strUser As String, ByVal_
strPwd As String, ByVal strOldPwd As String) As Integer
Dim ws As Workspace
Dim usr As User
On Error GoTo err_ChangePassword
Set ws = DBEngine.Workspaces(0)
Set usr = ws.Users(strUser)
usr.NewPassword strOldPwd, strPwd
err_ChangePassword:
If Err.Number = 3033 Then
MsgBox "You do not have permission to modify _
passwords. Please contact your system _
administrator."
End If
End Function
End Sub