By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,154 Members | 2,313 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,154 IT Pros & Developers. It's quick & easy.

opening a form using a listbox and a button

P: 2
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
Share this Question
Share on Google+
4 Replies


100+
P: 143
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

P: 2
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
Expert Mod 10K+
P: 14,534
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
Expert Mod 10K+
P: 14,534
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

Post your reply

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