Copy a form and make it a popup (6 Viewers)

mreinsmith

New member
Local time
Today, 17:44
Joined
Nov 25, 2024
Messages
13
I've been wrestling with making a form a popup and opening it

There are many alternatives but I thought I would try copying and renaming a form

Then changing the popup property and opening it

I keep getting can't find object when copying the form

I'm on mobile, I'll post some code when I get back to my desk

I should have waited to post but it's bugging the heck out of me

Matt
 
You'll probably have to check the code behind the form to trace the error.
 
Ok so I was able to copy the form

Code:
    Dim sourceFormName As String
    Dim destinationFormName As String

    sourceFormName = "Frm_Items"
    destinationFormName = "Popup_Items"

    DoCmd.CopyObject , destinationFormName, acForm, sourceFormName
 
    DoCmd.Close acForm, sourceFormName
 
    Dim NewForm As Form
    Set NewForm = Form(destinationFormName)

    NewForm.PopUp = True
 
    DoCmd.OpenForm destinationFormName

Now when I run it I get:

Run-time error '2467:

The expression you entered refers to an object that is closed or
doesn't exist.

on the line "Set NewForm = Form(destinationFormName)"

it was my understanding that you had to close the form to set the popup property
 
I've been wrestling with making a form a popup and opening it
Now that you've shown us your code and we can see the context, all I can say is why? When I read the question, I assumed you had copied the form in design view and were modifying it for use a a popup. I never envisioned doing this on the fly. What are you hoping to accomplish? AND, you will never be able to distribute this application as an .accde or for use with the Access runtime using this code.
 
I'm trying to do the impossible with building an interface...

I'm trying to pop out the forms to display them on another monitor(s)

BTW, I fixed some stuff in the code
 
Should have clarified that it's not an app yet
Every time you modify your code, you need to compile it to check for errors. This assumes you use Option Explicit at the top of every module.
 
Every time you modify your code, you need to compile it to check for errors. This assumes you use Option Explicit at the top of every module.
I've got to admit, I never made that a regular practice

I always just relied on compile on demand and the immediate window

Thanks
 
I always just relied on compile on demand and the immediate window
Now is as good a time as any to start applying best practices. Compile before you test - always. Fix compile errors immediately. Save your code frequently. During development, make many backups. I easily end up with a dozen or more for any given day. I don't keep all those backups for very long, usually just a few days but it has saved my bacon on more occasions than I care to remember. You never know when you are going to accidently delete something you've just spent hours perfecting or insert a bug or corruption. If you save frequently as well as C&R, you won't loose more than an hour or so of work. That can still be huge so I always look for good break points where I've got something that I can use as a base to build on.

Also, please tell us why you want to do this "live"? What do you hope to accomplish?
 

Users who are viewing this thread

Back
Top Bottom