[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 956
  • Last Modified:

Syscmd in Access

I am trying to determine if a form is open so i can perform a certain task. To do that i am running the syscmd. It works in certain places fine but not with this one scenario. This is the function i have set up.
Function IsFormOpen(sForm As String) As Boolean
If SysCmd(acSysCmdGetObjectState, acForm, sForm) = acObjStateOpen Then
  IsFormOpen = True
ElseIf Not SysCmd(acSysCmdGetObjectState, acForm, sForm) = acObjStateOpen Then
  IsFormOpen = False
End If

The acSysCmdGetObjectState is returning a value of 10? If i understood the help file does not even say that is an option?

here is the scenario

On Form A - Update form. Press a Button to :
Call Form B - Search form. Search Button
Calls Form C Search results form. Checks to see if B is open if yes closes Form B. this works
Append button on Form C checks to see if they have Form A still open. If yes then append data if No then msgbox. this does not work.

Any Idea's



0
PSIUnit
Asked:
PSIUnit
1 Solution
 
Rey Obrero (Capricorn1)Commented:
here is the sample code from the northwind db

Public Function IsLoaded(ByVal strFormName As String) As Integer
' From Northwind sample database:
' Returns True if the specified form is open in Form view or Datasheet view.
 
' These variables are used to test the return values of the SysCmd function
'  and the CurrentView property of the requested form.
    Const conObjStateClosed = 0
    Const conDesignView = 0

    'The first If statement uses the SysCmd function to check the current
    'state of the requested form. It can be in one of four states: not open
    'or nonexistent, open, new, or changed but not saved.
    If SysCmd(acSysCmdGetObjectState, acForm, strFormName) <> conObjStateClosed Then
       
        'The second If statement checks for the current view of the requested
        'form, assuming the previous If statement found it to be open. If
        'the form is currently open in Form View, the function will return
        'true. If the form is in Design View, the function will return false.
        If Forms(strFormName).CurrentView <> conDesignView Then
            IsLoaded = True
        End If
   
    End If
   
End Function
0

Featured Post

[Webinar] Kill tickets & tabs using PowerShell

Are you tired of cycling through the same browser tabs everyday to close the same repetitive tickets? In this webinar JumpCloud will show how you can leverage RESTful APIs to build your own PowerShell modules to kill tickets & tabs using the PowerShell command Invoke-RestMethod.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now