Solved

Displaying Form.....

Posted on 2000-03-17
8
171 Views
Last Modified: 2010-05-02
I have one text box......

then a user enters a form name in this textbox.....Now how do i display this  form object.....

tapsbin
0
Comment
Question by:tapsbin
8 Comments
 
LVL 4

Expert Comment

by:wileecoy
ID: 2630337
Can you give a little more information?

Are you giving the user a list of possible forms to enter?

If so, you should probably use a Select Case statement.

For example:


Select Case textbox.text
     case "Main"
          frmMain.Show
     case "About"
          frmAbout.Show
     ......etc
     case else
          msgbox "Please Enter A Valid Form"
end Select

That is a simple example in which the user is presented with a list of forms to select.

Please respond and let me know if I understood your question.  If not please explain where I missed the mark.

Thanks!
0
 

Expert Comment

by:Sankar030999
ID: 2630433
willecoy is correct. as far as i know, thats the way to do it.
but instead of using a text box, y dont u use a combo box and populate them with the form names. by this way, the user can select the form to be displayed by clicking on the combo box.
check it out...
0
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 2630441
You should list your form in a listbox to help user!!!
0
Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

 
LVL 5

Expert Comment

by:KDivad
ID: 2630607
If you "pre-load" all your forms, then this is a good way to do it:

For Each Form In Forms
    If Form.Name = Text1.Text Then
        FormFound = True
        Form.Show
        Exit For
    End If
Next
If Not FormFound Then MsgBox "No such form!"

Problem is: the Forms collection only contains loaded forms.
0
 
LVL 15

Expert Comment

by:ameba
ID: 2631201
Private Sub Text1_KeyPress(KeyAscii As Integer)
    On Error Resume Next
    If KeyAscii = vbKeyReturn Then Forms.Add(Text1.Text).Show ' requires VB6 SP3
End Sub
0
 
LVL 15

Accepted Solution

by:
ameba earned 50 total points
ID: 2631228
Option Explicit

Private Sub Form_Load()
    Text1.Text = "Form1"
End Sub

Private Sub Text1_KeyPress(KeyAscii As Integer)
    Dim frm As Form
    On Error GoTo EH
   
    If KeyAscii = vbKeyReturn Then
        Set frm = Forms.Add(Text1.Text)
        frm.Move Me.Left + 300, Me.Top + 300
        frm.Show
        KeyAscii = 0 ' prevent beep
    End If
    Exit Sub
EH:
    MsgBox Err.Description
End Sub
0
 

Author Comment

by:tapsbin
ID: 2651828
Will test and respond to you quickly.....
0
 

Author Comment

by:tapsbin
ID: 4121294
i have field with different form name. While looping through the field values, it should also invoke an instance of that form object, as well as should keep track of that instance, as and when needs to be fetched.

thanks
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

830 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