473,586 Members | 2,718 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 1184
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_Chang e()
On Error GoTo ErrPoint
Dim MyVar As String
MyVar = Me.MyListbox.Va lue
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_Chang e()
On Error GoTo ErrPoint
MyVar = Me.MyListbox.Va lue
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
3739
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 acouple of arrays loaded with the second selects values not to be shown till selected in first or what other means? Also how do you reload the current...
1
2467
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 entry form that may be incomplete or inconsistent before the user exits the record. These warnings take the form of items in a listbox. The...
6
1763
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 button. The queries behind the record use the listbox value (selected) as criteria to limit/build the report data.
3
7851
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 Access Database. I click 'Add Photo' on that form and after the OpenFileDialog (etc.), it asks me to save some information about the photo (caption...
4
6064
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 of a Custom User Control, generated by adding a new Custom User Control to a project with VS.NET.
2
1754
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 (ListBox) created on FormA. I have the listbox set to internal, however: I cannot seem to be able to access the selected value of the listbox. I am...
18
3334
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 columns, "scode" and "sname", as 1 column (if not possible then 2 columns will be fine) in the listbox. Can the listbox display 2 columns information...
3
11077
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 updates to show the other fields in the table. The problem I am having is when I enter text to search the table the list narrows successfully,...
8
6371
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 any feasible solution, i need to use a checked listbox which also has same flickering problem on resize. Thanks & Regards
0
7839
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...
0
8200
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8338
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...
1
7954
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...
0
6610
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
3836
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...
1
2345
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 we have to send another system
1
1448
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1179
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...

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.