Button To open new form does not close the main form

V

Veli Izzet

Hi all,

I put a button to open Sales form from Products form with the wizard,
but I also want to close the main form, Sales form, which I cannot.



While here, I have another question:

When I open a new from and input data into it, that data does not show
in the other open forms, before they are closed and opened again.

There must be a way to automatically requery instead of closing and
opening the forms.

Thanks for any help for the both questions.
 
R

Rick Brandt

Veli said:
Thanks Rick,

Where do I put this Requery command?

Two ways to go...

It could be in the close event of the second form, but that would imply that the
only time the second form is opened is from the first one. Otherwise you would
need to test for that.

The code in the first form could open the second using the acDialog option and
then requery itself on the next line of code...

DoCmd.OpenForm "SecondFormName",,,,,acDialog
Me.Requery

The acDialog argument causes the code block to pause until the second form is
closed or hidden. Then the Requery will fire.
 
V

Veli Izzet

Rick,

DoCmd.Close

Gives "Microsoft Office Access can't find the field '|' referred to in
your instruction"

What should that be?

The total code was created by the wizard and is:



Private Sub Command213_Click()
On Error GoTo Err_Command213_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = ChrW(83) & ChrW(97) & ChrW(116) & ChrW(305) & ChrW(351)
& ChrW(108) & ChrW(97) & ChrW(114)
DoCmd.OpenForm stDocName, , , stLinkCriteria
DoCmd.Close acForm, [TakilarFiyatlamali]
Exit_Command213_Click:
Exit Sub

Err_Command213_Click:
MsgBox Err.Description
Resume Exit_Command213_Click

End Sub

It opens the other form, but stops there.
 
R

Rick Brandt

Veli said:
Rick,

DoCmd.Close

Gives "Microsoft Office Access can't find the field '|' referred to in
your instruction"

What should that be?

The total code was created by the wizard and is:

The name of the form needs to be a string in quotes. Is TakilarFiyatlamali a
field on the form?
 
Top