I was searching for something similar and came across this old thread which really relates. I want to programmatically generate a form on the fly which is physically identical to one in my database, but with a new name. I'll describe below.
Sorry for the long explanation but I've found that it really helps if those reading the post understand the background and reasoning.
The form I've created is a visual duplicate of a Message Box, same color background, no record source, a label for the message and an OK button to close the form. The caption of the label is generated by concatenating fixed text with temporary variables.
To explain functionality and reasoning, we have a busy office and when people leave for lunch or break they initiate a logoff routine in Access. It doesn't actually close Access, but sets them as inactive along with the reason for them being gone (Lunch, Break) and the time they're expected back in a table. When they return, a click of an "I'm Back" button clears the info from the table and everything continues as normal.
A timed routine runs every minute and compares the expected return time with current time. If the person has not returned and current time is later than the expected return time, the simulated Message Box pops up on admin users screens saying, "Jesse was expected back from Break 4 minutes ago at 10:25 AM and has not logged back in yet."
You can see how the message is composed of a concatenated value of fixed and variable text.
The reason I want to use a form instead of a Message Box is because several users may be away. I'd like a form to be created as needed for any user who is late because suppose an Admin user is away from his/her desk and the message above pops up. Jesse returns and clears the routine as indicated, but the message remains on screen. Admin user returns and doesn't know if the person has returned or not.
The only way I can send a specific command to close is if I'm using a form instead of a Message Box, so that's the reasoning behind it. When late user returns we want to close the form on Admin screens.
The reasoning behind wanting a new form for each is so that there can be several forms and messages open on Admin screens. I'm going to name the forms UserName() & "Late". Now I would have a specific form for each person, along with the ability to close it on Admin screens centrally when user returns to their work station.
So, in a nutshell, I want to duplicate existing form LunchBreakReminder, and then delete the duplicate after closing it when the user returns so that I don't have fourteen gazillion forms in the system.
Does anyone have suggestions on how to accomplish this?