B
Barry A&P
I am now trying to clean up pages of messy code and i can do a lot of it with
a open form function
I am trying to add openargs to the openform function used in northwind..
i would like the code to open a form in whatever its default view may be if
open the strControlName is left out or ="" not sure how it has to be done.
and if a control is referenced get the value from that control and open the
form to a specific record.
currently the code locks up access and i have to restart.
heres what i have
Function OpenForms(strFormName As String, strcontrolname As String) As Integer
' This function is used in the Click event of command buttons that
' open forms on the Main Switchboard. Using a function is more efficient
' than repeating the same code in multiple event procedures.
' Use =OpenForms("Categories","me!snidcombo") in the controls event where
'categories is the name of the form and me!snidcombo would be the source for
openargs if needed
On Error GoTo Err_OpenForms
If CurrentProject.AllForms(strFormName).IsLoaded Then
DoCmd.Close acForm, strFormName
End If
If strcontrolname = "" Then
DoCmd.OpenForm strFormName
Else
DoCmd.OpenForm strFormName, , , , , , strcontrolname
End If
' Open specified form.
'old method DoCmd.OpenForm strFormName
Exit_OpenForms:
Exit Function
Err_OpenForms:
MsgBox Err.Description
Resume Exit_OpenForms
End Function
Thanks for any help
Barry
a open form function
I am trying to add openargs to the openform function used in northwind..
i would like the code to open a form in whatever its default view may be if
open the strControlName is left out or ="" not sure how it has to be done.
and if a control is referenced get the value from that control and open the
form to a specific record.
currently the code locks up access and i have to restart.
heres what i have
Function OpenForms(strFormName As String, strcontrolname As String) As Integer
' This function is used in the Click event of command buttons that
' open forms on the Main Switchboard. Using a function is more efficient
' than repeating the same code in multiple event procedures.
' Use =OpenForms("Categories","me!snidcombo") in the controls event where
'categories is the name of the form and me!snidcombo would be the source for
openargs if needed
On Error GoTo Err_OpenForms
If CurrentProject.AllForms(strFormName).IsLoaded Then
DoCmd.Close acForm, strFormName
End If
If strcontrolname = "" Then
DoCmd.OpenForm strFormName
Else
DoCmd.OpenForm strFormName, , , , , , strcontrolname
End If
' Open specified form.
'old method DoCmd.OpenForm strFormName
Exit_OpenForms:
Exit Function
Err_OpenForms:
MsgBox Err.Description
Resume Exit_OpenForms
End Function
Thanks for any help
Barry