A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Set up filter for listbox now ItemsSelected isn't read



 
 
Thread Tools Display Modes
  #1  
Old January 14th, 2010, 05:36 PM posted to microsoft.public.access.forms
Pamela
external usenet poster
 
Posts: 193
Default Set up filter for listbox now ItemsSelected isn't read

To make my form a little more dynamic for each entry the user inputs, I
decided to add cboVehicleType to my form which, when updated, requeries
lbDamagedParts to only include items related to the cbo selection. Before
adding this filter, everything worked perfectly.

On the BeforeUpdate event of the form, I have code to take the listbox
selections and concatenate them with some text into a sentence w/ commas
separating them. Now that I've set up the filter on the list box, the
resulting concatenation reads, ",,,, ." whereas there's supposed to be text
in between those commas.

To filter the box, I set up a many-to-many relationship between ltblParts &
ltblVehType w/ a junction table jtblVehTypePartsID as each Part will have
many Veh's it goes with and each VehType has many Parts. I set the
AfterUpdate event of the cbo to Requery my listbox and set the RecordSource
of my listbox to:
SELECT qryVehTypeParts.Expr1 FROM qryVehTypeParts WHERE
(((qryVehTypeParts.VehTypeID)=VehicleType));
(Expr1 has DLookup to display the PartName vs. just the ID which is
AutoNumber)

The code for concatenating the ItemsSelected is:
If Me.lbDamagedParts.ItemsSelected.Count 0 Then
For Each varRow In Me.lbDamagedParts.ItemsSelected
strText = strText & Me.lbDamagedParts.Column(1, varRow) & ", "
Next varRow
Me.Text39 = "The vehicle sustained damage to the " & _
Left(strText, Len(strText) - 2) & " and additional damage may be found
once the repairs begin."
Else
Me.Text39 = "The vehicle did not sustain any visible damage."
End If
Thanks so much for any help you can give!

Pamela
  #2  
Old January 15th, 2010, 04:06 AM posted to microsoft.public.access.forms
Tom van Stiphout[_2_]
external usenet poster
 
Posts: 1,653
Default Set up filter for listbox now ItemsSelected isn't read

On Thu, 14 Jan 2010 09:36:02 -0800, Pamela
wrote:

Your code looks good from a distance, but you need a closeup: set a
breakpoint at the top of this procedure and carefully step through.
Select View Locals Window and also use the Watch window to inspect
variables. Pretty soon you'll say "Eureka!"

-Tom.
Microsoft Access MVP


To make my form a little more dynamic for each entry the user inputs, I
decided to add cboVehicleType to my form which, when updated, requeries
lbDamagedParts to only include items related to the cbo selection. Before
adding this filter, everything worked perfectly.

On the BeforeUpdate event of the form, I have code to take the listbox
selections and concatenate them with some text into a sentence w/ commas
separating them. Now that I've set up the filter on the list box, the
resulting concatenation reads, ",,,, ." whereas there's supposed to be text
in between those commas.

To filter the box, I set up a many-to-many relationship between ltblParts &
ltblVehType w/ a junction table jtblVehTypePartsID as each Part will have
many Veh's it goes with and each VehType has many Parts. I set the
AfterUpdate event of the cbo to Requery my listbox and set the RecordSource
of my listbox to:
SELECT qryVehTypeParts.Expr1 FROM qryVehTypeParts WHERE
(((qryVehTypeParts.VehTypeID)=VehicleType));
(Expr1 has DLookup to display the PartName vs. just the ID which is
AutoNumber)

The code for concatenating the ItemsSelected is:
If Me.lbDamagedParts.ItemsSelected.Count 0 Then
For Each varRow In Me.lbDamagedParts.ItemsSelected
strText = strText & Me.lbDamagedParts.Column(1, varRow) & ", "
Next varRow
Me.Text39 = "The vehicle sustained damage to the " & _
Left(strText, Len(strText) - 2) & " and additional damage may be found
once the repairs begin."
Else
Me.Text39 = "The vehicle did not sustain any visible damage."
End If
Thanks so much for any help you can give!

Pamela

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 12:07 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.