use of arrays in forms (1 Viewer)

Bladerunner

Registered User.
Local time
Today, 11:38
Joined
Feb 11, 2013
Messages
1,799
I have a form that allows me to sell animals in a group. While some fields, (i.e. buyersname, sellingunits, datesold) are good for all, some fields (i.e. AnimalID, SellingWgt, Sellingprice, Picture) need to be specific.

Having said this, Using a query for GroupSales, I filled a list box of all the animals that are to be sold. Below the list box two command buttons (1-ALL) and (2-by Group).The only difference being here, is that by clicking cmdALL all animalIDs listed in the list Box will be highlighted. The By-Group means the user has to highlight the IDs they want to sell..

In either event, there will multiple IDs. If I can use arrays here, I could include the other fields for each animal that has been chosen. These would then be updated/appended to other tbls.

Anybody got any format info or just point me in the right direction. :)
 

smig

Registered User.
Local time
Today, 21:38
Joined
Nov 25, 2009
Messages
2,209
Put all fields into the listBox. Setting the columnWidth to 0 will hide them.
No need for array here.
 

Bladerunner

Registered User.
Local time
Today, 11:38
Joined
Feb 11, 2013
Messages
1,799
hello smig: What I want to do is sell a herd en' mass. I can pullup and fill the listbox based upon a query. Example: have 10 animals that are to be sold and these are pulled up in a query and fill a listbox. There are other parameters to be filled in (i.e. Av. Weight, Av Price, Date, etc.......). When I get these filled in, I simply press the savve button and it starts saving each animalID listed in the listbox along with the other parameters to the TblSales.

Of course there are variations such as being able to highlite the numbers (in listbox) to be recorded. (Maybe only 15 of the 30 animals listed are to be sold?) In this case if one animalID is highlited, it is all that is recorded.

Thanks for listening.

Blade
 

Bladerunner

Registered User.
Local time
Today, 11:38
Joined
Feb 11, 2013
Messages
1,799
My apologies to those who read this thread. I did not look deep enough into the properties of the listbox.. It has a multiselect (simple or extended) in the properties section of the control. However code will have to be used to report,save any items selected.

Blade.
 

smig

Registered User.
Local time
Today, 21:38
Joined
Nov 25, 2009
Messages
2,209
Here a piece of code that will help you with this:
Code:
Dim rs As DAO.Recordset
Dim varItemSelected As Variant

Set rs  = db.OpenRecordset("YourTable")
With rs 
    For Each varItemSelected In Me.YourListBox.ItemsSelected
          .AddNew
          .Fields("YourFieldName1") = Me.YourListBox.Column(0, varItemSelected )
          .Fields("YourFieldName2") = Me.YourListBox.Column(1, varItemSelected )
          .Fields("YourFieldName3") = Me.YourListBox.Column(2, varItemSelected )
          .Update
    Next varItemSelected 
    .Close
End With
Set rs = Nothing
 

Users who are viewing this thread

Top Bottom