Don't really know what to call it

  • Thread starter Thread starter Jan Il
  • Start date Start date
J

Jan Il

Hi all - Access 2000, WinME

I don't know if this is a formscoding or query situation. I am not sure what
to call what I need to do.

I need to create a form that will allow me call up specific multi-record
information to be reviewed, which may not be from the same Date frame, or
system Locations, for inspection comparison.

It is in regards to specific catenary equipment, that is due for replacement
due to excessive wear. The information for these area have been established
based upon line inspection and recorded in a table for each line. South
Line, East Line, Old Town Line, Bayside Line and MVW Line.

What I need to do is to be able to select multiple specific Equipment ID for
these various lines to review this information.

Now...I know that it is possible to use a combo box to select individual
equipment based on a query...both in a filter and regular form. But, is
there way that on a filter (driver) form, I can create a list and select
more than one equipment ID from that list and have the information for each
displayed in an associated form that is opened with a command button? Sorry
if I am not explaining too well...it is sort of confusing for me too.

Best regards,
Jan :)
 
Jan Il said:
Hi all - Access 2000, WinME

I don't know if this is a formscoding or query situation. I am not
sure what to call what I need to do.

I need to create a form that will allow me call up specific
multi-record information to be reviewed, which may not be from the
same Date frame, or system Locations, for inspection comparison.

It is in regards to specific catenary equipment, that is due for
replacement due to excessive wear. The information for these area
have been established based upon line inspection and recorded in a
table for each line. South Line, East Line, Old Town Line, Bayside
Line and MVW Line.

What I need to do is to be able to select multiple specific Equipment
ID for these various lines to review this information.

Now...I know that it is possible to use a combo box to select
individual equipment based on a query...both in a filter and regular
form. But, is there way that on a filter (driver) form, I can create
a list and select more than one equipment ID from that list and have
the information for each displayed in an associated form that is
opened with a command button? Sorry if I am not explaining too
well...it is sort of confusing for me too.

Best regards,
Jan :)

Hi, Jan -

I think at least part, if not all, of what you're asking would be
accomplished by presenting the user with a multiselect list box to
choose equipment IDs -- that is, a list box with its MultiSelect
property set to "Simple" (probably) rather than "None". From the
selected items in the list box, the code in the command button's click
event builds a criteria string to select just those pieces of equipment,
and uses it as the WhereCondition argument in the call to
DoCmd.OpenForm. So the opened form only displays those equipment IDs.

Does that sound like what you're looking for? If so, I can give you
example code to loop through the select items in a list box and build a
criteria string.
 
Hi Dirk!
Hi, Jan -

I think at least part, if not all, of what you're asking would be
accomplished by presenting the user with a multiselect list box to
choose equipment IDs -- that is, a list box with its MultiSelect
property set to "Simple" (probably) rather than "None". From the
selected items in the list box, the code in the command button's click
event builds a criteria string to select just those pieces of equipment,
and uses it as the WhereCondition argument in the call to
DoCmd.OpenForm. So the opened form only displays those equipment IDs.

Does that sound like what you're looking for? If so, I can give you
example code to loop through the select items in a list box and build a
criteria string.

As I understand it, they could select the various equipment ID's in the list
box, and then, based upon the code behind the click button, be able to call
up and review just those records for the pieces of equipment they selected.
If this is correct, then, yes, this is what I am trying to do.

The equipment involved are the sleds in the catenary system. They act to
sectionalize the power from one substation to the next within a given area
of the system. They are inspected and maintained in scheduled periods. Some
become too worn, or perhaps damaged during train movement, and need to be
replaced. They are inspected and measurements of their wear is recorded.
When funds are available for replacement, we need to be able to review those
that are in the most need of replacement. That is the purpose of this form.

Thank for your time and assistance.

Jan :)
 
Hi Dirk -

Dirk Goldgar said:
Jan Il said:
As I understand it, they could select the various equipment ID's in
the list box, and then, based upon the code behind the click button,
be able to call up and review just those records for the pieces of
equipment they selected. If this is correct, then, yes, this is what
I am trying to do.

The equipment involved are the sleds in the catenary system. They
act to sectionalize the power from one substation to the next within
a given area of the system. They are inspected and maintained in
scheduled periods. Some become too worn, or perhaps damaged during
train movement, and need to be replaced. They are inspected and
measurements of their wear is recorded. When funds are available for
replacement, we need to be able to review those that are in the most
need of replacement. That is the purpose of this form.

Thank for your time and assistance.

Okay, Jan, here's how it might work. I'll assume that the list box is
named "lstEquipment", its rowsource is set up to display the list of
sleds you wanto to choose from, its MultiSelect property is set to
"Simple", and its bound column contains the field [Equip ID], which is a
text field. I'll also assume for this example that you want to open a
form named "frmViewEquipment", and the command button to do this named
"cmdViewEquipment". (Please review these assumptions and make
corrections where necessary.) The code for the command button might
look like this:

'---- start of example code ----
Private Sub cmdReviewEquipment_Click()

Dim varItem As Variant
Dim strCriteria As String

With Me.lstEquipment

For Each varItem In .ItemsSelected
strCriteria = strCriteria & ", '" & .ItemData(varItem) & "'"
Next varItem

If Len(strCriteria) = 0 Then
MsgBox "Please choose one or more items from the list, " & _
"then click the button.", _
vbInformation, _
"Choose Equipment First"
Exit Sub
End If

If .ItemsSelected.Count = 1 Then
strCriteria = "= " & Mid$(strCriteria, 3)
Else
strCriteria = "In (" & Mid$(strCriteria, 3) & ")"
End If

End With

strCriteria = "[Equip ID] " & strCriteria

DoCmd.OpenForm "frmReviewEquipment", WhereCondition:=strCriteria

End Sub
'---- end of example code ----

I'm guessing you're also going to need a button to "unselect" all the
items in the list, preparing it for use again. As an added bonus,
special today for our valued customers, here's code for that:

'---- start of code for "clear selections" button ----
Private Sub cmdClearList_Click()

Dim intI As Integer

With Me.lstEquipment

For intI = (.ItemsSelected.Count - 1) To 0 Step -1
.Selected(.ItemsSelected(intI)) = False
Next intI

.SetFocus
.ListIndex = Abs(.ColumnHeads)
End With

End Sub
'---- end of code for "clear selections" button ----

Does that cover everything you needed?

May I assume that it is possible to print this form out as a report? I know
this is not the normal procedure, and under normal circumstances I would not
consider it, but, since there will most likely only be less than 5 or 6
items, I am thinking that it might not be worth the time to create a special
report for this if it can be printed from the form as a report.

Jan :)
 
HI Dirk -
Yes, Jan, it's possible to print a form, though I can't vouch for the
"prettiness" of the results, as I always use reports for printing. You
can do it through the user interface by choosing File -> Print (or
pressing Ctrl+P) when the form has the focus, and I think you can do it
programmatically with DoCmd.PrintOut.

In addition, you can get a jump-start on creating a report by opening
the form in Form View or Design View, then choosing File -> Save As...,
and specifying that the form should be saved as a report. Then you can
look at the output of that report and modify the report in design view
to fix it up if you want.

Ah... I see. 'k..that is where I made the mistake, not doing the save as
'report'. OkieDoke, I'll give that a try.

Thanks! ;-))

Jan :)
 
Hi Dirk!
Okay, Jan, here's how it might work. I'll assume that the list box is
named "lstEquipment", its rowsource is set up to display the list of
sleds you want to choose from, its MultiSelect property is set to
"Simple", and its bound column contains the field [Equip ID], which is a
text field. I'll also assume for this example that you want to open a
form named "frmViewEquipment", and the command button to do this named
"cmdViewEquipment". (Please review these assumptions and make
corrections where necessary.) The code for the command button might
look like this:

'---- start of example code ----
Private Sub cmdReviewEquipment_Click()

Dim varItem As Variant
Dim strCriteria As String

With Me.lstEquipment

For Each varItem In .ItemsSelected
strCriteria = strCriteria & ", '" & .ItemData(varItem) & "'"
Next varItem

If Len(strCriteria) = 0 Then
MsgBox "Please choose one or more items from the list, " & _
"then click the button.", _
vbInformation, _
"Choose Equipment First"
Exit Sub
End If

If .ItemsSelected.Count = 1 Then
strCriteria = "= " & Mid$(strCriteria, 3)
Else
strCriteria = "In (" & Mid$(strCriteria, 3) & ")"
End If

End With

strCriteria = "[Equip ID] " & strCriteria

DoCmd.OpenForm "frmReviewEquipment", WhereCondition:=strCriteria

End Sub
'---- end of example code ----

I'm guessing you're also going to need a button to "unselect" all the
items in the list, preparing it for use again. As an added bonus,
special today for our valued customers, here's code for that:

'---- start of code for "clear selections" button ----
Private Sub cmdClearList_Click()

Dim intI As Integer

With Me.lstEquipment

For intI = (.ItemsSelected.Count - 1) To 0 Step -1
.Selected(.ItemsSelected(intI)) = False
Next intI

.SetFocus
.ListIndex = Abs(.ColumnHeads)
End With

End Sub
'---- end of code for "clear selections" button ----

Does that cover everything you needed?

The first part of the code, for the step for the lstEquipment worked
perfectly (I changed the actual name to that of my control>
and everything works great.

However, with the Clear Selections part of the code, it does not
work when I click that button. I don't get an error message, it just does
nothing. It complies without any hissy fits...but..it does not clear the
items in the list box. I have not done this type of function before,
so...perhaps I don't understand how this should work. When the list box
comes
up is shows the list of sled ID's as it should. And I can select one, or
two, and then click the command button to bring up the information for that
sled(s) in the related form. This all works fine. But, when I click the
Clear Selection command button, with the code that I copied from here direct
to the command button code, it just does not do anything.

The mistake is mine somewhere, being that this is my first time with this
type
of function. I have tried it several times, and tried to troubleshoot as
best I can, but, I am not sure where to look for any other problem areas,
and obviously, I am missing something.

Jan :)
 
Jan Il said:
The first part of the code, for the step for the lstEquipment worked
perfectly (I changed the actual name to that of my control>
and everything works great.
Good.

However, with the Clear Selections part of the code, it does not
work when I click that button. I don't get an error message, it just
does nothing. It complies without any hissy fits...but..it does not
clear the items in the list box. I have not done this type of
function before, so...perhaps I don't understand how this should
work. When the list box comes
up is shows the list of sled ID's as it should. And I can select
one, or two, and then click the command button to bring up the
information for that sled(s) in the related form. This all works
fine. But, when I click the Clear Selection command button, with the
code that I copied from here direct to the command button code, it
just does not do anything.

Hmm, the code works in principle; it's copied from a form of mine on
which it works. Verify the following:

1) You changed the name of the list box in the code, "lstEquipment", to
the name of your list box.

2) You replaced the command button name "cmdClearList" in the event
procedure declaration with the name of your button, so that instead of
"cmdClearList_Click", it's "<your button name>_Click".

3) On the property sheet for that command button, the "On Click" event
property says "[Event Procedure]" (without the quotes).
 
Hi Dirk!
Hmm, the code works in principle; it's copied from a form of mine on
which it works. Verify the following:

1) You changed the name of the list box in the code, "lstEquipment", to
the name of your list box.

No, I renamed the list box lstEquipment so that we would be on the same page
with the code. The name of the box made no difference at the start, so I
renamed it to match your code.
2) You replaced the command button name "cmdClearList" in the event
procedure declaration with the name of your button, so that instead of
"cmdClearList_Click", it's "<your button name>_Click".

As I had not created that button yet, I just named it the same as the name
you used, so we would still be in sync with the code.
3) On the property sheet for that command button, the "On Click" event
property says "[Event Procedure]" (without the quotes).

Yes.

Thus far I have only two sled records I am using to sample the form and list
box, and they are both showing in the list when it is first opened. When I
select one and click the select button which opens the record form, and then
go back to the filter form, the record I selected is still highlighted. When
I click on the Clear all button, the one I selected is no longer
highlighted, but, the two sled ID's are still showing in the box. So,
perhaps the code is actually working, I am just not understanding what it is
doing, not having used a list box before.

Jan :)
 
Thus far I have only two sled records I am using to sample the form
and list box, and they are both showing in the list when it is first
opened. When I select one and click the select button which opens the
record form, and then go back to the filter form, the record I
selected is still highlighted. When I click on the Clear all button,
the one I selected is no longer highlighted, but, the two sled ID's
are still showing in the box. So, perhaps the code is actually
working, I am just not understanding what it is doing, not having
used a list box before.

Oh, then the code is doing what it is supposed to -- or at least, it's
doing what I intended it to, although that may not be what *you* had in
mind. :-) It's "un-selecting" the items in the list box, but it's not
removing them from the list. If you wanted to actually empty the list,
all you'd have to do is set the list box's RowSource to a null string:

Me.lstEquipment.RowSource = ""

Of course, then you'd have to have a mechanism for resetting the list
box's RowSource to fill the list again. But you may already have that.
 
Hi Dirk!

Dirk Goldgar said:
Oh, then the code is doing what it is supposed to -- or at least, it's
doing what I intended it to, although that may not be what *you* had in
mind. :-) It's "un-selecting" the items in the list box, but it's not
removing them from the list. If you wanted to actually empty the list,
all you'd have to do is set the list box's RowSource to a null string:

Me.lstEquipment.RowSource = ""

Of course, then you'd have to have a mechanism for resetting the list
box's RowSource to fill the list again. But you may already have that.

'k..as long as I know that it is doing what it is supposed to, and how it
all works, that is fine. I just usually use combo boxes, and did not know
exactly what to expect with the list box as a first time user. So, if it
ain't broke, I won't try to fix it ;-)

Thanks for all your help, I really appreciate it.

Jan :)
 
Back
Top