Synching with a Pop up form

D

Dave

I have a "Create Orders" form. Sometimes I need to create an order for a
new customer (one that does not exist in the database). So on the Create
Orders form there is a command button whose click event will open the
"Create Customer" form in acFormAdd mode. I am then able to create the new
customer. I close the "Create Customer" form but now I need to requery my
"Create Orders" form so that the new customer record will show up as an item
in a combo box.

How can I do this?

And is there a difference between Me.Requery and Me.Dirty = False?
 
M

Michel Walsh

Hi,


Me.Dirty=false save the current record (of the form represented by
"Me" ), a Requery retrieve records added by other users since the last time
you open the form (other users include VBA code, which is another user, if
you use CurrentDb.Execute "INSERT INTO ... " ). A Requery also refresh a
list ( through the RowSource property of a combo box, as example). A Requery
on a form or on a recordset invalidates the bookmark and reposition at the
start. A simple SAVE just does that, saving the values of the actual record.


Hoping it may help,
Vanderghast, Access MVP
 
D

Dave

Michael,

Thanks for explaining the difference.

Do you know how I can requery my main form when I close my pop-up form?

I imagine I need to put something like "f_CreateOrders.requery" in the close
event of my f_CreateCustoner form. But f_CreateCustomer may be used by
itself rather than as a pop-up. In this case f_CreateOrders would not be
open and I would get an error.

How can I test if f_CreateOrders is open before I try to requery it?
 
M

Michel Walsh

Hi,



To know if a form is open you can check

CBool( SysCmd(acSysCmdGetObjectState , acForm, "FormNameHere") )


or you can look if there is an index "i" so that

Forms(i).Name = "FormNameHere"


since Forms is the collection of all open forms.




Hoping it may help,
Vanderghast, Access MVP
 
D

Dave

Thanks Michael

I added the following code to the onClose event of the poup form and it
seems to work fine.

Dim i As Integer
Dim c As Integer

c = Forms.Count - 1

For i = c To 0 Step -1
If Forms(i).Name = "f_check" Then
' MsgBox ("open")
Forms!f_check.Requery
End If
Next

Thanks again for your help.
 

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