Results 1 to 5 of 5
  1. #1
    Join Date
    Oct 2002
    Location
    Leicester - UK
    Posts
    820

    Unanswered: after update runs after close

    how do i stop the form closing until after i've closed the form opened in the after update method every thing i try either lock the DB or have no effect

    basicly what i need is

    sub form_onClose
    if form2 is open wait
    docmd close me.name
    endsub

    i've tried putting the 1st form in a do loop until canClose
    were the second form sets canClose = true on closing and it just locked the db until i did CTRL Break
    Definition of a Beginner, Someone who doesn't know the rules.

    Definition of an Expert, Someone who knows when to ignore the rules.

  2. #2
    Join Date
    Jan 2003
    Posts
    46
    You might want to nest a function reference in your IF statement to see whether a particular form is open. here is the function (credit for which goes to someone else):

    Public Function IsOpenForm(FormName As String) As Boolean
    'SysCmd Returns 0 If Object Is Not Open
    'Form Name Must Have Double Quotes Around It, I.E. "Form1", Not Form1
    If SysCmd(acSysCmdGetObjectState, acForm, FormName) <> 0 Then
    IsOpenForm = True
    Else: IsOpenForm = False
    End If
    End Function

    Cheers
    zambezibill

  3. #3
    Join Date
    Oct 2002
    Location
    Leicester - UK
    Posts
    820
    Originally posted by zambezibill
    You might want to nest a function reference in your IF statement to see whether a particular form is open. here is the function (credit for which goes to someone else):

    Public Function IsOpenForm(FormName As String) As Boolean
    'SysCmd Returns 0 If Object Is Not Open
    'Form Name Must Have Double Quotes Around It, I.E. "Form1", Not Form1
    If SysCmd(acSysCmdGetObjectState, acForm, FormName) <> 0 Then
    IsOpenForm = True
    Else: IsOpenForm = False
    End If
    End Function

    Cheers
    zambezibill
    the problem with that is it doesn't wait for the forms state to change it just tests once then goes away what i need is something like process switching where the close form code tells the other form that it's waiting for it to close abd then goes to sleep, the form then notifyes the observing form which can then continue closing the form (In java it the observer and observable classes)
    Definition of a Beginner, Someone who doesn't know the rules.

    Definition of an Expert, Someone who knows when to ignore the rules.

  4. #4
    Join Date
    Jan 2003
    Posts
    46
    You are correct, the function merely checks once to see if a designated form is open. There is no Java equivalent.

    But, if the function returns True (the form is open), your code needs to instruct the desired form to close. Then you can continue with other actions/events.

    Cheers,
    zambezibill

  5. #5
    Join Date
    Oct 2002
    Location
    Leicester - UK
    Posts
    820
    Originally posted by zambezibill
    You are correct, the function merely checks once to see if a designated form is open. There is no Java equivalent.

    But, if the function returns True (the form is open), your code needs to instruct the desired form to close. Then you can continue with other actions/events.

    Cheers,
    zambezibill
    you misunderstand the java example i gave is what i need vb to do what your suggesting is not and at most fixes some of the problem leaving the main problem untouched, and i cant use your second suggestion because of the fact that i can't close the other form until the user has finished with it but the user cant use the form unless the other is open basicly the second form is a pop up that evaluates the data on the first form and prompts the user if they wish to do the special processing on the data and then does it, now this works perfectly in every area other than the form closing as the data to be evaluated is nolonger there if if is impossible to tell the first form to wait for the other form to close or even to sit i the back ground and test every few seconds to see if the form is open and close it's self after the other form to close then i guess i need to find some way of informing the second form that in this case opposed to any other it has to close both form no just it's self.
    Last edited by m.timoney; 02-28-03 at 07:10.
    Definition of a Beginner, Someone who doesn't know the rules.

    Definition of an Expert, Someone who knows when to ignore the rules.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •