How to create equivalent of a pop-up subform?

P

PBear

I want to create a (non-modal) pop-up form that acts like a subform -- i.e.,
it opens from a button on the main form, it's linked to the main form and
will update and synchronize itself as I cycle through each record in the
database on the main form.

[I've run out of room on the main form (I want to keep the entire database
window limited to 1024x768 pixels for sake of portability) and I don't want
to use tab pages (I want to be able to see the picture and the data on screen
at the same time).]

The pop-form will display one visible field, a picture control -- in Access
2007 this is an Attachment-type field, using its own built-in thumbnail
collector. I've had no trouble creating the pop-up form, and can set the
OnClick event for the calling button so that the window will pop up and
display the Picture for the current record selected on the main form:
DoCmd.OpenForm "frmPictures", , , "[Video_ID] =" & Me![ID], acFormEdit, , [ID]

The first problem is that the above command opens the window in a "Filtered"
state, with only one record showing -- I can't figure out any way to have
that window pop up unfiltered. (I've currently got the Picture data stored
in a separate, linked table -- should I make that a field in the main table
instead?)

The rest of the problems are, how do I:

1. Keep the records on the pop-up form in synch with the main form as I
cycle through records in the main form?

2. Deal with records in which the Picture field is blank (which are many of
them)?

3. Deal with different behaviours, depending on whether the pop-up windows
is open or closed (once open, I'll probably want to keep it open most of the
time)?

I just wish Access had a built-in method for allowing floating subforms!

Any ideas, severally or variously, will be appreciated.

Thanks.
 
L

Linq Adams via AccessMonster.com

If you want it to act like a subform the best thing to do is to use a subform!


The usual way to do this is to use a standard subform then control its
visibility rather than opening/closing a faux "subform."

Set up a subform as usual.

This example uses a command button called OpenCloseButton.

Place it on your main form.

In Properties set

Visible to "No"

Caption to "Open"

Then in code behind the button:

Private Sub OpenCloseButton_Click()

If OpenCloseButton.Caption = "Open" Then
Me.YourSubForm.Visible = True
OpenCloseButton.Caption = "Close"
Else
Me.YourSubForm.Visible = False
OpenCloseButton.Caption = "Open"
End If

End Sub

replacing

OpenCloseButton

with your button's actual name and

YourSubForm

with the name of your subform control. Be sure to use the name of the control,
which may or may not be the same of the form the subform is based on.

When the main form opens the subform will be "invisible" and the button will
say "Open." Click on the "Open" button and the subform will "appear" and the
button will now say "Close." Clicking the button will toggle the subform
between "visible" and "invisible."
 

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