Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Question using "Set frm = New Form_myForm"

Posted on 2009-07-03
6
Medium Priority
?
345 Views
Last Modified: 2013-11-28
Hi All,

I have created a new pop-up form that I want to be able to create multiple instances of.  To do this I am using:

Dim frm as Form
Set frm = New Form_myForm

My question is, I want to be able to somehow pass the form name to be opened to this via an argument in a function, like so:

fOpenForm(myFormName), and then have it activate like this:

Set frm = New Form_ & myFormName

although I know this doesn't work.  Any ideas how I can pass different form names to "New Form_...")?
0
Comment
Question by:MitchellVII
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 85
ID: 24774148
AFAIK you cannot do this ... this is an example of early binding, and in order to do this the compiler would have to know what, exactly, to "bind" ... if you use a variable the compiler would have no idea what type of object to expect and would choke.

You might try something like this:

Function fOpenForm(FormName As String) As Form
  Dim frm As Object

  Set frm = forms(FormName)
  Set fOpenForm = frm
End Function

Then call it like this:

Dim frm As Form
Set frm = fOpenForm("frmCustomers")

I'm not sure this will work, but it may ...


0
 
LVL 5

Author Comment

by:MitchellVII
ID: 24774205
I think most of my confusion comes from trying to use the "New Form_" thing to open a form so that i can open multtiple instances of the same form.  I really don't understand why Access doesn''t make this sort of thing easier since it is something pretty much anyone might want to do.

Is there a way to open multiple instances of a form WITHOUT using the "New Form_" syntax?
0
 
LVL 85

Accepted Solution

by:
Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 2000 total points
ID: 24774234
In order to open multiple forms you MUST set those new instances to a "New" instance of the form, so no, you cannot do this without using the New keyword.

I'd perhaps agree with you regarding multiple instances, and there is some discussion going on about this in the MVP newsgroups ... I'm not sure it's a greatly needed feature, but I can see where it would be helpful at times. That said, many users would get very confused working with the same form (different data) and could (almost certainly would) end up altering the wrong data or some such. With data-centric apps, to me SDI interfaces (at least from the standpoint of a single form) are a much better alternative.

Can you describe more of what you're doing, and why multiple instances of the same form would be beneficial?
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 5

Author Comment

by:MitchellVII
ID: 24774320

LSM,
In my database, I have continuous records forms that utilize some pretty cool "drag n' drop" code I wrote for moving records around.

One thing i wanted to be able to do is have a pop-up "detail" form that would appear and then drag to wherever I wanted to work on it when I clicked on a field.  The benefit of being able to do this with mutpiple forms is that i could compare the details on multiple records simultaneously.

For example, the idea is that I can click on a simple "Log_ID" Field on my continuous form as a little Detail Popup Form for that Log Entry would appear and I could drag it to a spot i wanted to work on it.
I was just trying to streamline the process by passing the popup form name as an argument, but since i can't do that with " New Form_...", I just write a Select Case statement and iterate through the 8 possibiltiies, kind of like this:

'Open Snapshot PopUp:
Select Case strDragSnapshot
    Case "ContactSnapshotEdit"
        Set frmDrag = New Form_ContactSnapshotEdit
    Case "JobSnapshotEdit"
        Set frmDrag = New Form_JobSnapshotEdit
    Case "MatchSnapshotEdit"
        Set frmDrag = New Form_MatchSnapshotEdit
    Case "BookingSnapshotEdit"
        Set frmDrag = New Form_BookingSnapshotEdit
    Case "LogSnapshotEdit"
        Set frmDrag = New Form_LogSnapshotEdit
    Case "JournalSnapshotEdit"
'        Set frmDrag = New Form_JournalSnapshotEdit
    Case "DocumentSnapshotEdit"
        Set frmDrag = New Form_DocumentSnapshotEdit
    Case "PostSnapshotEdit"
        Set frmDrag = New Form_PostSnapshotEdit
End Select
Anyway, it may be kludgey, but it works fine so I'll go with it.
0
 
LVL 58
ID: 24777292
You might want to pick up a copy of the Access Developers Handbook published by Sybex.  It includes code for handling multiple form instances via a user defined collection.
That code also includes logic to manipulate the caption of each form so you have better control over them.
It also has a section on doing multiple instances for pop-up forms.
JimD.
0
 
LVL 5

Author Comment

by:MitchellVII
ID: 24778077
Thanks Jim :)
0

Featured Post

Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…
Suggested Courses

721 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question