Open a form when another form is updated

S

shaggles

I'm working with an Access 97 db that I inherited from a
previous admin. It requires 2 forms to be updated with
the same information. I want to make form B open
automatically after form A is updated and closed. I don't
want it to open everytime someone closes form A (the form
is used for viewing information as well as entering) or
after every update to form A (there are frequently
multiple updates) so I thought something like this would
work:
Private Sub Form_Close()

On Error GoTo Err_Form_On_Close

Dim DocName As String
Dim LinkCriteria As String
DocName = "Form_B"
LinkCriteria = "[SS#] = Forms!Form_A![SS#]"
If Me.Dirty Then

DoCmd.OpenForm DocName, , , LinkCriteria
End If


Exit_Form_On_Close:
Exit Sub

Err_Form_On_Close:
MsgBox Error$
Resume Exit_Form_On_Close


End Sub
 
D

Dan Artuso

Hi,
I'm not sure I follow you're logic as to when form b should be opened,
but you can try something like this.

Declare a boolean variable in the declarations section of your form,
that is, at the top before any subs or events. Let's call it bDirty.

Set it to true in the After Update event of your form. Then in the close event:
If bDirty Then
.........

See if that works for you.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top