473,508 Members | 2,168 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Calling another Form from a Listbox.

1 New Member
I have a form that has a Listbox that when you set the Event Procedure to a "Click" or "Enter", I want to have it open a 2nd form based on what was selected in the dropdown. Does anyone have the VB code to paste in and modify for the event procedure for this?
Sep 8 '08 #1
1 1174
DonRayner
489 Recognized Expert Contributor
If you want to open the new form as soon as you select it then put your code into the controls Changet event


Private Sub MyListbox_Change()
On Error GoTo ErrPoint
Dim MyVar As String
MyVar = Me.MyListbox.Value
DoCmd.OpenForm MyVar
ExitPoint:
Exit Sub
ErrPoint:
MsgBox "Error# " & Err.Number & " " & Err.Description
Resume ExitPoint
End Sub

If you want to use another event or button to open the form, then declare the MyVar as a public variable at the top of the module right after the option statements

Option Compare Database
Option Explicit

Public MyVar as string

Then your sub would look like this

Private Sub MyListbox_Change()
On Error GoTo ErrPoint
MyVar = Me.MyListbox.Value
ExitPoint:
Exit Sub
ErrPoint:
MsgBox "Error# " & Err.Number & " " & Err.Description
Resume ExitPoint
End Sub

Finally wherever control or event is to activate the form add into it

DoCmd.OpenForm MyVar

Hope this helps
Sep 18 '08 #2

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

Similar topics

2
3735
by: JJ | last post by:
Hi All, When someone selects a value in a select on a form I want to show the same form with another select with certain values depending on first select. How can I do this? Should I keep...
1
2459
by: bruce | last post by:
Hello, I have a small form that pops up when a user moves off the current record of a rather sizeable data entry form. The purpose of this form is to list warnings about various fields on the...
6
1758
by: NOSPAMrclark | last post by:
I'm wondering . . . . What is the generally accepted method for calling reports from multiple locations? Example: REPORT-A is called by selecting a record in a listbox and clicking a...
3
7841
by: Brian Basquille | last post by:
Hey there all, Fairly easy question for a C# expert, i assume! Am still working on my Photo Album. On frmBrowsePhotos, i have a listBox (photosList) containing photoID's from a table in an...
4
6060
by: Paradox | last post by:
Hey, I'm trying to figure out what situations call for the use of a derived form control such as: public class myListBox : System.Windows.Forms.ListBox and what situations call for the use...
2
1746
by: Andy | last post by:
I have a form (formA). This form used to following code on FormA to load a new form(FormB). formB f = new formB(); f.ShowDialog(); However: on formB, I am unable to access any object...
18
3321
by: Alpha | last post by:
Hi, I'm working on a Windows applicaton with VS 2003 on windows 2000. I have a listbox that I have binded to a dataset table, "source" which has 3 columns. I would like to display 2 of those...
3
11069
by: Brian | last post by:
I have a form that has a textbox used to search records in a table. On the form I have a listbox which shows each record in the table. When you click on each row in the listbox the rest of the form...
8
6363
by: nirdeshonline | last post by:
Hi, I have added a simple listbox in windows form under c# 2.0. It contains a collection of approx 10 strings as list items. Now when i resize the form whole listbox flickers. Please tell me...
0
7127
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...
0
7391
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...
1
7054
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...
1
5056
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...
0
4713
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...
0
3188
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1564
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
768
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
424
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...

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.