Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

If IsOpened 1

Status
Not open for further replies.

samotek

Technical User
May 9, 2005
197
BG
I want to build a common function that is functioning when a certain form is opened and nothing happens when such a form is not opened.I presume I must use the line If ISOpened but I cannot do it properly.Could you help me ?

Public Function MyBack()
If IsOpened Forms!frmClients Then
Forms!frmClients![Registered] = ""
DoCmd.Close acForm, "frmClients”
Else If
Forms!frmCustomers Then
Forms!frmCustomers!Registered = “”
DoCmd.Close acForm, "frmCustomers”
Else If
Forms!Orders! Then
Forms!Orders!Registered = “”
DoCmd.Close acForm, "Orders”
End If

End Function
 
Can you post the contents of your IsOpened function?

The usual way to programmatically check if a form is open is to use SysCmd (acSysGetObjectState, acForm, Formname)

John
 
No i donmet have such a function. And yes, now i understand why it doesnt work.I thought it is a built in function but obviously i must refer to some IsOpened function. Could you post me your suggestion ?
 
What condition did you want on your second Else If - you just look at a form, there's nothing to compare it against?

John
 
in the second If, if the form FrmCustomers is opened,
i want to make :
Forms!frmCustomers!Registered = ""
and then close the form
 
Is there ever the possibility of having more than one form open at once?

John
 
A very crude way:
Code:
On Error Resume Next
Forms!frmClients!Registered = ""
DoCmd.Close acForm, "frmClients"
Forms!frmCustomers!Registered = ""
DoCmd.Close acForm, "frmCustomers"
Forms!Orders!Registered = ""
DoCmd.Close acForm, "Orders"

Another way:
Code:
For Each strForm In Array("frmClients", "frmCustomers", "Orders")
  If CurrentProject.AllForms(strForm).IsLoaded Then
    Forms(strForm)!Registered = ""
    DoCmd.Close acForm, strForm
  End If
Next

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top