473,549 Members | 5,196 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

opening a form using a listbox and a button

2 New Member
Hey room, in Access 2000 in the VB part. Im trying to open a form after selcting a value from a list box. Once you select the value you click a button which then opens a form with the details from the list box on it. The list box is called list15 and the button command12. The form has not been created yet as there is alot of work to be done!

Thanks for your help.

Dave
Oct 13 '06 #1
4 10537
Tanis
143 New Member
You need to use the OpenArgs method. Create your listbox and a command button. Behind the command button place this code.

Dim strFormName As String
Dim stLinkCriteria As String

strFormName = "MyForm"
DoCmd.OpenForm strFormName, , , , , , Me.MyListBox

Don't forget to change the form name and listboxname. Next, in the forms, that you are opening, ON LOAD event place this code.

Me.MyTextBox = Me.OpenArgs

Again, change the name of the text box that is on the form.That should do it. By the way, you don't need a command button. Place the first section of code in the After Update event of the list box.
Oct 13 '06 #2
daveleak781
2 New Member
You need to use the OpenArgs method. Create your listbox and a command button. Behind the command button place this code.

Dim strFormName As String
Dim stLinkCriteria As String

strFormName = "MyForm"
DoCmd.OpenForm strFormName, , , , , , Me.MyListBox

Don't forget to change the form name and listboxname. Next, in the forms, that you are opening, ON LOAD event place this code.

Me.MyTextBox = Me.OpenArgs

Again, change the name of the text box that is on the form.That should do it. By the way, you don't need a command button. Place the first section of code in the After Update event of the list box.
what do the dots in DoCmd.OpenForm strFormName, , , , , , Me.MyListBox mean? i would need some detail if you could please?
Oct 13 '06 #3
MMcCarthy
14,534 Recognized Expert Moderator MVP
To open a form to a specific record you need to pass the criteria using the following format. In the code FormField is the field on the form that holds the data matching the listbox.

DoCmd.OpenForm FormName, , , WhereCondition

Expand|Select|Wrap|Line Numbers
  1.  
  2. Private Sub Command12_Click()
  3.     DoCmd.OpenForm "FormName", , , "[FormField]=" & Me.List15
  4. End Sub
  5.  
  6.  
Oct 14 '06 #4
MMcCarthy
14,534 Recognized Expert Moderator MVP
DoCmd.OpenForm FormName, , , WhereCondition

By the way the commas in this statement stand for parameters we don't need. You need to put them in to show the WhereCondition statement
Oct 14 '06 #5

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

Similar topics

5
4471
by: jdph40 | last post by:
I have a form in Access 97 on which I have an unbound list box filled with our employees names from tblEmployees. When you select an employee's name and click a button, the following code is run and another form opens with only that employee's data: For Each varSelected In Me!EmpList.ItemsSelected strSQL = strSQL &...
3
5008
by: Simon Rowe | last post by:
Probably really simple but I cant work it out... I have a list box on a form with a few records in. When I open the form the first record is sort of highlight with a dashed box, when I cursor down the record changes to inverse video and from then on I can sroll up and down the records with the inverse video highlight. I just cant seem to...
3
7846
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
6061
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.
18
3326
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...
2
4859
by: baret bonden | last post by:
Trying to return a selected listbox item to another form .tried lots of ways; defining public variables and passing those as well as textboxes ..I' m able to display the chosen item on it's form in a textbox and I'm able to pass other variables to the 2nd form, but not the data I want . I should add this is a smartdeviceapplication(if that...
3
6517
by: Work007 | last post by:
i am using visual basic express edition and i am very new to it. I have a form 1 which has a textbox. User adds something to this textbox and clicks on the ADD button. User is taken to form 2 and the value has been added to a listbox. on this form 2 there is a listbox which stores values from the previous form. I also have a button on this...
3
2075
by: EManning | last post by:
I''m having problems getting a form to open while going from one tab to another. I have a tab control: one tab for counties and one tab for cities. Both tabs have multi-select listboxes. If some, but not all, counties are chosen, then all cities in the selected counties are automatically highlighted when the user exits the county tab and...
5
2501
by: lukasmazur | last post by:
Hi I have a problem with using listBox1. I have a two forms form1 and form2. In form1 are controls listBox1, textBox1 and button witch creating object of class Form2. In class Form2 I create a pointer to object of class Form1. I don't known how to use method add(), where can I find it. From Form1 I can add value like this this->listBox1-...
0
7526
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...
0
7723
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. ...
1
7480
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
7814
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...
0
6050
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
3504
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...
0
3486
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1949
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
0
769
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.