Multiply List Boxes

  • Thread starter Thread starter Jasper Recto
  • Start date Start date
J

Jasper Recto

Ok,

New List box question. I have a form that has one list box that is linked
to a table. The items on the table are Report Description
Report Name
Report Path

I have a button that has an event that executes the program to run the
reports:

Private Sub Command2_Click()
ReportPath = Me.List0.Column(3)
ReportName = Me.List0.Column(2)

"shell command for the report"

End Sub

The shell command uses for the 'reportpath' and 'reportname' from the list
box that the user selects.

My question is, how would I go about adding multiply list boxes and have the
same functionality from one button?

First, if I have multiply list boxes, how can I make it so only one item
from any of the list boxes can be select. As of right now, I can select one
from each box. The use should only be able to select on from all the boxes.

Second, how can I pass the information over to the button so it knows with
item was selected.

Thanks,
Jasper
 
Jasper Recto said:
Ok,

New List box question. I have a form that has one list box that is
linked to a table. The items on the table are Report Description
Report Name
Report Path

I have a button that has an event that executes the program to run the
reports:

Private Sub Command2_Click()
ReportPath = Me.List0.Column(3)
ReportName = Me.List0.Column(2)

From your description, these should actually be

ReportPath = Me.List0.Column(2)
ReportName = Me.List0.Column(1)
My question is, how would I go about adding multiply list boxes and
have the same functionality from one button?

You mean, "multiple"?
First, if I have multiply list boxes, how can I make it so only one
item from any of the list boxes can be select. As of right now, I
can select one from each box. The use should only be able to select
on from all the boxes.

Add code to the AfterUpdate event of each list box, that sets the other
two to Null; e.g.,

Private Sub List0_AfterUpdate()
Me.List1 = Null
Me.List2 = Null
End Sub

Private Sub List1_AfterUpdate()
Me.List0 = Null
Me.List2 = Null
End Sub

Private Sub List2_AfterUpdate()
Me.List0 = Null
Me.List1 = Null
End Sub
Second, how can I pass the information over to the button so it knows
with item was selected.

In this simple case, I think I'd just have the button check each of the
list boxes:

Private Sub Command2_Click()

Dim lst As Access.ListBox

If IsNull(Me!List0)
If IsNull(Me!List1)
If IsNull(Me!List2)
MsgBox "Choose from one of the lists first!"
Exit Sub
Else
Set lst = Me!List2
End If
Else
Set lst = Me!List1
End If
Else
Set lst = Me!List0
End If

ReportPath = lst.Column(2)
ReportName = lst.Column(1)

Set lst = Nothing

' ... shell command for the report ...

End Sub
 
Sorry about the typo,

I'm having a little issue. In the Private Sub Command2_Click() statement , the 'If IsNull statements are all Red and the program won't run:

Private Sub Command2_Click()

Dim lst As Access.ListBox

If IsNull(Me!List0)
If IsNull(Me!List1)
If IsNull(Me!List2)
MsgBox "Choose from one of the lists first!"
Exit Sub
Else
Set lst = Me!List2
End If
Else
Set lst = Me!List1
End If
Else
Set lst = Me!List0
End If

ReportPath = lst.Column(3)
ReportName = lst.Column(2)

Set lst = Nothing

'Execute Report Builder w/ Report
' ... shell command for the report ...
End Sub

Any ideas why?
Thanks,
Jasper
 
Jasper Recto said:
Sorry about the typo,

I'm having a little issue. In the Private Sub Command2_Click()
statement , the 'If IsNull statements are all Red and the program
won't run:

Private Sub Command2_Click()

Dim lst As Access.ListBox

If IsNull(Me!List0)
If IsNull(Me!List1)
If IsNull(Me!List2)

Oops. Should have been

If IsNull(Me!List0) Then
If IsNull(Me!List1) Then
If IsNull(Me!List2) Then

Of course, you'd use the names of your own list boxes, if they aren't
List0, List1, and List2.
 
Perfect!
Thanks for all your help!!
Jasper
Dirk Goldgar said:
Oops. Should have been

If IsNull(Me!List0) Then
If IsNull(Me!List1) Then
If IsNull(Me!List2) Then

Of course, you'd use the names of your own list boxes, if they aren't
List0, List1, and List2.

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)
 
Back
Top