Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Listbox problem and selection of All records

Status
Not open for further replies.

cbuono

IS-IT--Management
Nov 11, 2001
11
US
Hey guys, I need some major assistance with a listbox I've been fighting with for the last couple of hours.

I have a query (that is selecting from table Pallet) that is populating a listbox. I've also used a Union query to add the text "ALL" at the top of the listbox. Now my issue is that if the user selects all how to have to data that is being passed back in the form. I've tried to find the specific value(s) of the selections but it always seems to be coming back with errors.

Here's the code so far:

DoCmd.SetWarnings False
Dim varData As Variant
Dim myctl As Control
Dim ctllook As Variant

Set myctl = Forms![frm_main].[frm_par_pallet].Form![list_palletkey]

For Each varData In myctl.ItemsSelected
DoCmd.RunSQL "Insert into tbl_lookup_pallet_palletkey (palletkey) select '" & myctl.ItemData(varData) & "'", -1
Next varData

ctllook = DLookup("[palletkey]", "tbl_lookup_pallet_palletkey", "[palletkey]='ALL'")
If ctllook Is Not Null Then
stDocName = "qry_insert_palletkey_lookup"
DoCmd.OpenQuery stDocName, acNormal, acEdit
Else
For Each varData In myctl.ItemsSelected
DoCmd.RunSQL "Insert into tbl_lookup_pallet_palletkey2 (palletkey) select '" & myctl.ItemData(varData) & "'", -1
Next varData
End If

After this is completed the the form does a requery based on looking up the parameters in tbl_lookup_pallet_palletkey2. Maybe this is really roundabout but if anyone has any assistance or suggestions for me I would really appreciate it.

Thanks is advance.
Chris
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top