Wrox Programmer Forums
|
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 26th, 2006, 12:01 PM
Registered User
 
Join Date: Apr 2006
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default help

how to write VBA code in A form to check whether B form is open or not, if yes, refresh B form, if not, exit, I tried many ways, but always error happen, I can done refresh parts, but "how to check Bform is open or not" always has error, I'm new, Thanks for help

 
Old April 26th, 2006, 02:21 PM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

You may need to do some error handling here. It is okay if there are errors if you handle them properly.

For example, if you use:

On Error Resume Next

at the beginning of your code to check for form B, then check the value of the error, like:

If Err <> 0 Then
...

This is the case where the form is not open. If Err = 0, then there was no error and the form was open. If you know the exact error value, like -24000789 etc, then you can just check for the value.

Remember to reset the Err value with Err.Clear after each routine.

Does this help?

mmcdonal
 
Old April 26th, 2006, 02:38 PM
Registered User
 
Join Date: Apr 2006
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

mmcdonal, thanks for your help. I think my function is not right. can you check for me. Thanks

Private Sub Form_Close()

If OpenForm.[FRM Order] = True Then <--------- something wrong at here
    If Error <> 0 Then
        Forms![FRM Vendor].Refresh
        DoCmd.Close [FRM Vendor]
        Else
        Forms![FRM Order].Refresh
    End If
End If
End Sub










Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.