How to update main form when closing pop up form and...


D

doyle60

How do I requery the main form when I close a pop up form that, after
being filled out, changes data on the main form?

More specifically, I have a button on the main form that bolds the
type if there is data connected to the record that is entered on a pop
up. This bolding works just great and is very helpful to users.

Except when the user fills out the data on the pop up and closes the
pop up, the button does not bold right away. It only bolds if you
joggle from one record to the other, of course. So I want to requery
the form when the pop up is closed BUT, and this is the tricky part as
you probably know, I want the main form to stay on the same record
after the requery.

By the way, though I do not think it matters, I get my Command button
to bold with a hidden subform and another control on the main form.

Main Form Name: EntryForm2
Key Field: PO
Hidden Subform: VTIPOBNLinkfrm
Hidden Control: VTIID (Control source: =[VTIPOBNLinkfrm].[Form]!
[VTIID])
Command Button to bold: Command5453

Popup Form: VTIHeaderfrm

Thanks,

Matt
 
Ad

Advertisements

J

Jack Leach

If you open the form as acDialog, just use a requery method after the line
that calls the form.

DoCmd.OpenForm frmname, , , , , acDialog
Me.Requery
Me.SubformControl.Form.Requery


hth
--
Jack Leach
www.tristatemachine.com

"I haven't failed, I've found ten thousand ways that don't work."
-Thomas Edison (1847-1931)
 
D

doyle60

I don't know what you mean by "If you open the form as acDialog." The
main form is already open and the pop up is open. I'm asking how to
update the record on the main form when the pop up is closed and for
the main form to remain on the current record after the requery.

The pop up opens from code created by the wizard when placing a
command button down when in design view. I don't know what acDialog
means.

It seems to me that you are suggesting a method for requerying the pop
up when it itself it being opened. That is not the issue. I want the
main to requery when the pop is closed.

Thanks,

Matt
 
J

Jack Leach

acDialog is a window mode option when opening a form via the DoCmd.OpenForm
method. When opened as a Dialog, all other code is suspended until the form
is closed (or hidden). So, the line Me.Requery will not run until after the
'pop-up' is closed. The Me.Requery line is called from your main form and
refers to the main form, so, it will requery the main form (after the form
opened as acDialog is closed).

I forget what code the wizard puts in, but if it's DoCmd.OpenForm to open
the form (I'm pretty sure it is), then check the arguments and the second to
last one should be the window mode, where you will put the vba constant
acDialog.

If the wizard doesn't have you set up opening the form this way, I would
suggest writing the code yourself, using the DoCmd.OpenForm method, utilizing
the acDialog windowmode argument.

Also note that when a form is opened as Dialog, you cannot change focus in
the application until that form is closed (or hidden). So, nobody will
accidentally forget to close a detail form.

I'm pretty sure this is standard procedure for what you are trying to do.
Check out the DoCmd.OpenForm help for more info.

So your code would run like this...

'Open the form in dialog mode
DoCmd.OpenForm "formname", , , , , acDialog
'now all the code for the opened form will run,
'but nothing in this module until that form is closed
'User saves changes/exits form

'This procedure now continues
'Requery the main form now that changes have been
'made in the detail
Me.Requery



hth
--
Jack Leach
www.tristatemachine.com

"I haven't failed, I've found ten thousand ways that don't work."
-Thomas Edison (1847-1931)
 
D

doyle60

Before I get started I just want to make sure about something. My pop
up is synchronized with the main form. It moves along to the proper
record when the user goes from record to record on the main form.

Is this a problem with the plan you wrote up?

I don't want to make it "sticky." I want users to freely change data
on the main as well as the pop when the pop is up.

Boy! I thought this would be easy code.

Thanks,

Matt
 
J

Jack Leach

My apologies... I thought you just had a regular detail form that opened to
edit a record and then got closed again (in which case opening the form as a
Dialog works great).

Unfortunately I've never had to do something like this and anything else I
might offer could end up as a wild goose chase.

Good luck
--
Jack Leach
www.tristatemachine.com

"I haven''t failed, I''ve found ten thousand ways that don''t work."
-Thomas Edison (1847-1931)
 
Ad

Advertisements

D

doyle60

Thanks Jack.

Can anyone else offer me help?

All I really want is code on the onclose even of a pop up to requery a
form and leave that form on the same record after the requery.

Thanks,

Matt
 

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