Need to requery a main form with a pop up form

T

troy23

I have a main form which has a balance for each record.

This form opens a pop up form where I enter payments.

When the pop up closes it should update the balance on the main form.

When I try to use requery in my code I find the main form suddenly
disappears.

I need it to update the balance and stay on the record that called the
pop up

Here is my code for the pop up. It is run from a close button and It
basically makes sure the record is the one that was called.



Dim FormName As String, SyncCriteria As String
Dim F As Form, rs As Object

FormName = "frmInvoiceMain"

Set F = Forms(FormName)
Set rs = F.RecordsetClone

SynchCriteria = "OrderID = " & Me.InvoiceID

rs.FindFirst SynchCriteria
F.Bookmark = rs.Bookmark

DoCmd.Close
 
C

CrazyAccessProgrammer

When you requery a form, a result of that action is the form will move to the
first record of its recordset.

Try to use refresh or repaint:

Open you're popup form where you enter your payments in dialog mode. Dialog
mode has the neat effect of halting execution of code after the openform (in
dialog mode) command until your popup form is closed.

DoCmd.OpenForm "FormName", acNormal, , , acFormEdit, acDialog

After the popup form is closed by the user, the code execution on your
parent form will continue, add the following lines after the code that opens
your popup form:

me.form.refresh: me.form.repaint

refesh updates the values of controls bound to fields.
repaint updates the value of unbound calculated controls on your form.

Depending on your needs, you may not need both refresh and repaint, so try
each one separatley by itself to see if you get the desired results.
 
T

troy23

Thanks for the reply.

Those are some interesting points I never knew about.

I still don't get the balance updated though when my form closes.

It only shows the updated balance if I move to another record and come
back again.

I wonder if I should put the find code after the code that opens the
pop up.
 
T

troy23

When you requery a form, a result of that action is the form will move tothe
first record of its recordset.

Try to use refresh or repaint:

Open you're popup form where you enter your payments in dialog mode. Dialog
mode has the neat effect of halting execution of code after the openform (in
dialog mode) command until your popup form is closed.

DoCmd.OpenForm "FormName", acNormal, , , acFormEdit, acDialog

After the popup form is closed by the user, the code execution on your
parent form will continue, add the following lines after the code that opens
your popup form:

me.form.refresh: me.form.repaint

refesh updates the values of controls bound to fields.
repaint updates the value of unbound calculated controls on your form.

Depending on your needs, you may not need both refresh and repaint, so try
each one separatley by itself to see if you get the desired results.
Got it working thanks.

I used your idea, but put find code after the code that opens the pop
up.

Just used a goto control, find record.

Seems to do it

Many thanks
 

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