473,698 Members | 2,445 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Open a form with a specific name

3 New Member
Hi,

I have a pretty basic question that I can't seem to figure out. I'm trying to open a form with a specific name that changes depending on the value of a cell.

For instance (simplified)...

Expand|Select|Wrap|Line Numbers
  1. sub openForm()
  2.  
  3.      dim formNumber as integer
  4.      formNumber = cells(1,1)
  5.  
  6.      dim fileName as string
  7.      fileName = "UserForm_" & formNumber
  8. End Sub
I now want to open the form named 'fileName' as defined above. How can I do this???


Thanks!!!
Jan 31 '07 #1
6 2017
iburyak
1,017 Recognized Expert Top Contributor
Hi,

I have a pretty basic question that I can't seem to figure out. I'm trying to open a form with a specific name that changes depending on the value of a cell.

For instance (simplified)...

sub openForm()

dim formNumber as integer
formNumber = cells(1,1)

dim fileName as string
fileName = "UserForm_" & formNumber

I now want to open the form named 'fileName' as defined above. How can I do this???

end sub

Thanks!!!

Can you just set a Caption of a new form to your fileName?

Like this:

[PHP]Dim frm As New Form1

frm.Caption = fileName
frm.Show[/PHP]
Jan 31 '07 #2
darren28
3 New Member
hmmm...couldn't get that to work. what is form1? my vb didn't recognize that.

i'm assuming that all the userforms are already created and existing in the vbproject. however, the user determines which form to open based on the value of the cell. therefore, assuming the user inputs "36", the exiting form named "UserForm_3 6" will open. I'm hoping there's an easy way to do this w/o doing 50+ case/else statements.

thx!
Jan 31 '07 #3
willakawill
1,646 Top Contributor
Are there that many forms or are you using the same form with a different caption?
Jan 31 '07 #4
darren28
3 New Member
there will be close to that many forms although not all will be imported/loaded
Jan 31 '07 #5
willakawill
1,646 Top Contributor
there will be close to that many forms although not all will be imported/loaded
Then you need to loop through the forms collection to find the one you need
Expand|Select|Wrap|Line Numbers
  1. Dim frm As Form
  2.  
  3. formName = "UserForm_" & formNumber
  4.  
  5. For Each frm In Forms
  6.    If frm.Name = formName Then
  7.       'do what you want to do with this form
  8.       frm.Show
  9.    End If
  10. Next frm
Feb 1 '07 #6
iburyak
1,017 Recognized Expert Top Contributor
I didn't think you wher talking about Excel form. I thought is is VB.
But code is the same just default form name is different.

[PHP]
Dim frm As New UserForm1
frm.Caption = fileName
frm.Show
[/PHP]
Feb 1 '07 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

3
23929
by: BLUE WATER | last post by:
Hi, I have managed to simplify my problem but can't seem to get this to work. I want to open up a form from a click event of another form, but not only open the form when the button is pressed but also move to the last record. DoCmd.OpenForm "My-Form-Name", acNormal Opens the form with no problem.....
115
14111
by: TheAd | last post by:
At this moment I use MsAccess and i can build about every databound application i want. Who knows about a serious open source alternative? Because Windows will be a client platform for some time, i prefer a solution that (also) supports Windows. On the net I found a number of products that i looked at, but none of them gave me the impression of a serious candidate at this moment (KNoda, Gnome DB Manager, InterBase...). 2 additional...
7
2748
by: TDIOwa | last post by:
I have a form that has a specific date on it. I want to open another form that has the Active Control Calendar on it. I want to open this form to the specific date on the first form. I have searched this forum high and low to find a solution and have tried virtually everything mentioned, all to no avail. Some solutions even crash the computer. Does anyone have any ideas? Thanks TD
1
3625
by: Mike Cox | last post by:
Hi. I added a button to a form so it opens up a report. The reason for this is that I want to print the data in *that* specific form in a specific formatted manner. Unfortunately, the report starts at page 1, instead of lets say record 1,500 which I want to open in the report and print. I have to manually type the correct page number. How do I set it so it opens the report and the report would be on page 1,500 AND it would only print...
4
3172
by: piscogirl | last post by:
Hi all, Here's my case: I have a form: Event Form and a subform: AttendanceSubForm The user selects a name (from a Person Table) on the subform to register for the event. If the name is not there, they are to click a
12
2233
by: Orchid | last post by:
Hello all, I have different version of reports which used for different months. For example, I am using report version 1 up to September, but we have some design changes on the report for October, so I created report version 2. I want a same Command Button to open the appropriated version report for the specific month. I create a table with the following Fields: Month, ReportID, ReportToOpen (this is the exact report name). On a form,...
1
1874
by: Don Croner | last post by:
I am using access 2003 with windows xp. I have created a data base for to keep track of my 180 employees. I have created a table with 21 records. Then I created a form to input employee data. I then created a switchboard to open a blank form. Now I want to use the swithchboard to open the form to a specific text box. ie, Edit Active Employees. I would like to do this by last name or SSN, two of the fields in the table. I can get it to...
5
9466
by: Ian | last post by:
I am trying to: 1. Open a form on the external database 2. Enter a value in a text box on that form I have 1 above working OK using module form “The Access Web”, the module looks like this: ************ Code Start ************* ' This code was originally written by Dev Ashish.
2
3535
by: eko99312 | last post by:
Let's say I have this form called Attendance List. The list was in datasheet form. In the list there were names and date checklist. The question is, I want to edit one of the names by double clicking on the datasheet and it will pop up Employee Form. To pop up Employee Form by double clicking on the names are easy, but the trick is I want the Employee Form shows the specific name that I wanted (or the specific name record), normally it will open...
0
8675
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8604
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9029
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8897
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8862
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6521
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5860
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4370
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
3
2002
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.