473,486 Members | 1,984 Online
Bytes | Software Development & Data Engineering Community
Create 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 10529
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
4465
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...
3
5005
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...
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
6055
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...
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...
2
4850
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...
3
6505
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...
3
2073
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...
5
2495
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...
0
6964
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
5430
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,...
1
4864
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
4559
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
3069
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...
0
3070
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1378
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
598
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
262
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.