I need a symple piece fo code that could be inserted in a command button's click event. It would check if form1 is opened, and if it is then open form2. Should be easy foar a VBA programmer, very difficult for me though
Thank you in advance.
I need a symple piece fo code that could be inserted in a command button's click event. It would check if form1 is opened, and if it is then open form2. Should be easy foar a VBA programmer, very difficult for me though
Thank you in advance.
Last edited by ser01; 02-26-2010 at 08:14 AM.
Open a module in access and paste the following function:
Public Function funIsLoadedForm(ByVal strFormName As String) As Boolean
' Returns True if the specified form is open in Form view or Datasheet view.
On Error GoTo Error_funIsLoadedForm
Const conObjStateClosed = 0
Const conDesignView = 0
If SysCmd(acSysCmdGetObjectState, acForm, strFormName) <> conObjStateClosed Then
If Forms(strFormName).CurrentView <> conDesignView Then
funIsLoadedForm = True
End If
End If
Exit_funIsLoadedForm:
Exit Function
Error_funIsLoadedForm:
MsgBox "Error in funIsLoadedForm: " & Err.Number & " - " & Err.Description
Resume Exit_funIsLoadedForm
End Function
Now open the from on which you have the command button from where you want to check whether say Form1 is open.
If funIsLoadedForm("Form1") = True thenDo whatever you have to doEnd If
type the above code in your onClick event in the command button.
please mark this thread if this solves your problem.
Thank you very much, works great!Open a module in access and paste the following function:
Public Function funIsLoadedForm(ByVal strFormName As String) As Boolean
' Returns True if the specified form is open in Form view or Datasheet view.
On Error GoTo Error_funIsLoadedForm
Const conObjStateClosed = 0
Const conDesignView = 0
If SysCmd(acSysCmdGetObjectState, acForm, strFormName) <> conObjStateClosed Then
If Forms(strFormName).CurrentView <> conDesignView Then
funIsLoadedForm = True
End If
End If
Exit_funIsLoadedForm:
Exit Function
Error_funIsLoadedForm:
MsgBox "Error in funIsLoadedForm: " & Err.Number & " - " & Err.Description
Resume Exit_funIsLoadedForm
End Function
Now open the from on which you have the command button from where you want to check whether say Form1 is open.
If funIsLoadedForm("Form1") = True thenDo whatever you have to doEnd If
type the above code in your onClick event in the command button.
please mark this thread if this solves your problem.