UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> Use Form Name As String To Open Form Without Docmd.openform, Office 2007    
 
   
hk1
post Jun 13 2012, 08:08 AM
Post #1

UtterAccess Veteran
Posts: 446



Is it possible to open a form using the Form's name as a string value without using DoCmd.OpenForm?

Dim frm As Form
Set frm = New Form_frmItemDetails 'Want to use string value here instead
frm.Visible = True
MyForms.Add Item:=frm, key:=CStr(frm.hwnd)
Set frm = Nothing

I've seen where people use a Select Case statement for each form. But that still requires you to go in and add a new option to your Select Case Statement any time you create a new form.
Go to the top of the page
 
+
Doug Steele
post Jun 13 2012, 08:21 AM
Post #2

UtterAccess VIP
Posts: 18,465
From: St. Catharines, ON (Canada)



No, I don't think it's possible.

What advantage did you hope to gain from not using OpenForm?


--------------------
Doug Steele, Microsoft Access MVP
http://www.accessmvp.com/DJSteele/AccessIndex.html
Co-author: Access Solutions: Tips, Tricks, and Secrets from Microsoft Access MVPs, published by Wiley
Technical Editor: Access 2010 Bible, published by Wiley, Access 2013 Bible, published by Wiley.
Go to the top of the page
 
+
hk1
post Jun 13 2012, 08:30 AM
Post #3

UtterAccess Veteran
Posts: 446



Basically, multiple instances of the same form. I use this enough I was thinking about abandoning the default Forms collection and writing the necessary code to duplicate that functionality along with multiple instances of the same form.

It looks like it's feasible, as long as I'm willing to use a Select Case statement and add each form to that.

Also, someone else was asking about this same thing over at StackOverflow:
http://stackoverflow.com/questions/1091789...nce-with-string
Go to the top of the page
 
+
Doug Steele
post Jun 13 2012, 08:59 AM
Post #4

UtterAccess VIP
Posts: 18,465
From: St. Catharines, ON (Canada)



Well, using Set frm = New Form_frmItemDetails is certainly required in order to instantiate multiple version of the same form, but I don't really see any advantage to have a generic routine capable of opening any form.

While it doesn't address the question you've asked about generalizing the creation of a new form instance, you might still be interested in reading what Allen Browne has at Managing Multiple Instances of a Form.


--------------------
Doug Steele, Microsoft Access MVP
http://www.accessmvp.com/DJSteele/AccessIndex.html
Co-author: Access Solutions: Tips, Tricks, and Secrets from Microsoft Access MVPs, published by Wiley
Technical Editor: Access 2010 Bible, published by Wiley, Access 2013 Bible, published by Wiley.
Go to the top of the page
 
+
hk1
post Jun 13 2012, 09:11 AM
Post #5

UtterAccess Veteran
Posts: 446



The problem with have two different form collections is that it can be confusing when you want to check to see if an instance of a form is already open, or if you need to get any kind of information regarding all open forms.

Thanks for the link to Allen Browne's code. I think I'm using it already and I think I've taken it a step further to check to make sure that we don't open two instances of the same form, set to the same Record ID. I'm using a public variable for this but in retrospect I think it would be better to just reference to the form's recordset directly, although it's more difficult to right a generic routine for this since my ID fields are not identically named or even predictably named.
Go to the top of the page
 
+

Thank you for your support! Reply to this topicStart new topic

Jump To Forum:
 



RSS Search  ·  Go to Top  ·  Lo-Fi Version Time is now: 22nd July 2014 - 08:22 AM