Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - Anyone know much about access programming
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Anyone know much about access programming

 Post Reply Post Reply Page  12>
Author
ziwez0 View Drop Down
Groupie
Groupie


Joined: 15 July 2002
Location: United Kingdom
Status: Offline
Points: 144
Post Options Post Options   Thanks (0) Thanks(0)   Quote ziwez0 Quote  Post ReplyReply Direct Link To This Post Topic: Anyone know much about access programming
    Posted: 14 October 2003 at 10:34am

Ive been playing around with programming in access recently but have come across a stumble block,

i have two tables one that contains dates and the other contains customer information (fname lname dob etc)

i have a form(called form1) that has a drop drop down box that connects to the first table (dates) and have a list box thats contains the customer info, basically when you select a date from the drop down box it then looks up the customer info table and sees what customers are in on that date and then displays in in the list box.

so..

it all works fine but it only displays the first name of the customer, where i want it to displat the first name, last name and party name.

here is the code

List2.RowSource = "Select [First Name], [Last Name], [Party Name] from [new diver] where [new diver].[check in]=[Forms]![Form1]![Combo0];"

any help on this would be great!

If anything takes long to do its worth doing.
Back to Top
Bunce View Drop Down
Senior Member
Senior Member
Avatar

Joined: 10 April 2002
Location: Australia
Status: Offline
Points: 846
Post Options Post Options   Thanks (0) Thanks(0)   Quote Bunce Quote  Post ReplyReply Direct Link To This Post Posted: 16 October 2003 at 4:24am

If you bring up the properties of the list box, there should be an option for setting the number of columns to display.  Change that to 3/4 and you should be right.

Cheers,
Andrew

There have been many, many posts made throughout the world...
This was one of them.
Back to Top
ziwez0 View Drop Down
Groupie
Groupie


Joined: 15 July 2002
Location: United Kingdom
Status: Offline
Points: 144
Post Options Post Options   Thanks (0) Thanks(0)   Quote ziwez0 Quote  Post ReplyReply Direct Link To This Post Posted: 16 October 2003 at 4:29am

cheers Andrew, worked that one out this morning,

just a another question, do you know how to get  mutilple values from one list box, click a button and it will add it into a second list box, if it had a remove button to that would be good..

thanks.

If anything takes long to do its worth doing.
Back to Top
Bunce View Drop Down
Senior Member
Senior Member
Avatar

Joined: 10 April 2002
Location: Australia
Status: Offline
Points: 846
Post Options Post Options   Thanks (0) Thanks(0)   Quote Bunce Quote  Post ReplyReply Direct Link To This Post Posted: 16 October 2003 at 4:38am

From memory, it stores your selected values in an array called somethng like listbox.selecteditems() or something.

So with button_onclick() event, you'll need to iterate through that array, and apply it to the recordsource of your second listbox.

Can't recall much more than that without going into Access.  Check out Access help for how your selected values are stored in a list box and see if you can work it out from there.

If not, report back and let me know.

Cheers,
A



Edited by Bunce
There have been many, many posts made throughout the world...
This was one of them.
Back to Top
Bunce View Drop Down
Senior Member
Senior Member
Avatar

Joined: 10 April 2002
Location: Australia
Status: Offline
Points: 846
Post Options Post Options   Thanks (0) Thanks(0)   Quote Bunce Quote  Post ReplyReply Direct Link To This Post Posted: 16 October 2003 at 4:49am

oops, rather than apply it to the recordsource of your second listbox, you would need to use the 'addItem' method of the second listbox, and add them one at a time as you iterate through that array/collection of selecteditems.

Cheers,
Andrew

There have been many, many posts made throughout the world...
This was one of them.
Back to Top
Bunce View Drop Down
Senior Member
Senior Member
Avatar

Joined: 10 April 2002
Location: Australia
Status: Offline
Points: 846
Post Options Post Options   Thanks (0) Thanks(0)   Quote Bunce Quote  Post ReplyReply Direct Link To This Post Posted: 16 October 2003 at 4:57am

OK.  I got curious and had to have a look!!   I was close..

The selected items are held in a collection which you can get at by using:
ListBox1.ItemsSelected

So you need to iterate through these items using:
For Each SelItem in Listbox1.ItemsSelected

To get at the actual text value of each selected item within the loop, use:
Listbox1.ItemData(SelItem)

And add it to the second listbox using something like:
Listbox2.Additem (Listbox1.ItemData(SelItem))

Thats the basics.. Check out Access help for the specifics of each.

Cheers,
A



Edited by Bunce
There have been many, many posts made throughout the world...
This was one of them.
Back to Top
ziwez0 View Drop Down
Groupie
Groupie


Joined: 15 July 2002
Location: United Kingdom
Status: Offline
Points: 144
Post Options Post Options   Thanks (0) Thanks(0)   Quote ziwez0 Quote  Post ReplyReply Direct Link To This Post Posted: 16 October 2003 at 5:27am

Andrew, cheers for the help ive just punched in the code you gave me...

-----Listbox1----------

Private Sub Listbox1_Click()
Listbox1.ItemSelected
For Each SelItem In Listbox1.ItemSelected
Listbox1.ItemData (SelItem)
End Sub

-----Listbox2-------

Private Sub Listbox2_AfterUpdate()
Listbox2.AddItem (Listbox1.ItemData(SelItem))
End Sub

And it dont work...?

where does the button come invloved?

Cheers buddy

If anything takes long to do its worth doing.
Back to Top
Bunce View Drop Down
Senior Member
Senior Member
Avatar

Joined: 10 April 2002
Location: Australia
Status: Offline
Points: 846
Post Options Post Options   Thanks (0) Thanks(0)   Quote Bunce Quote  Post ReplyReply Direct Link To This Post Posted: 16 October 2003 at 5:36am

The code I gave you won't work as it is.  You'll need to look in Access help to get the specifics.  It was just a starter.

Where does the button come involved? You said initially that you wanted to copy the selected items when clicking a button.  Therefore you need create a button on the form, and in the _onclick() event, place all your code in there.

It will basically look something like this, however there are other things you must set up also (see help) :

Private Sub Button1_OnClick()

   For Each SelItem In Listbox1.ItemSelected
      Listbox2.AddItem (Listbox1.ItemData(SelItem))
   Next

End Sub

I strongly suggest you look at some of the examples in Access help, that way you will learn some of the syntax so you can do these types of things for yourself in the future.

Good luck!

There have been many, many posts made throughout the world...
This was one of them.
Back to Top
 Post Reply Post Reply Page  12>

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.