Hi all
I have two listbox's in my form and they are both run from two
different queries. Below each listbox is a command button (Delete)
used to delete an entry in the listbox.
Now behind the command button for listbox 1 I have the following code;
If Nz(Me!List1, "") = "" Then
MsgBox "Nothing Selected"
Else
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "8-b COPPERBINDELETE"
stLinkCriteria = "[BINPROCESSID]=" & Me![txtBinProcessID]
DoCmd.OpenForm stDocName, , , stLinkCriteria
End If
End Sub
Now If I don't click a selection from listbox 1 then an error message
appears saying "Nothing selected" now I've tried to apply the same
code to the command button of listbox 2 but it doesn't work
If Nz(Me!List2, "") = "" Then
MsgBox "Nothing Selected"
Else
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "9-b GENERALBINDELETE"
stLinkCriteria = "[BINPROCESSID]=" & Me![txtBinProcessID]
DoCmd.OpenForm stDocName, , , stLinkCriteria
End If
End Sub
The code continues to run even if nothing is selected from listbox 2.
Any ideas why this is happening and how to go about resolving this
issue?
Thanks
Scott McDaniel - 29 Jun 2007 12:02 GMT
>Hi all
>
[quoted text clipped - 17 lines]
>End If
>End Sub
Try something like this:
If Nz(Me.List1.Column(0), 0) =0 Then
Msgbox "Nothing Selected"
Exit Sub
End If
<other code here>
>Now If I don't click a selection from listbox 1 then an error message
>appears saying "Nothing selected" now I've tried to apply the same
[quoted text clipped - 17 lines]
>
>Thanks
Scott McDaniel
scott@takemeout_infotrakker.com
www.infotrakker.com
RoyVidar - 29 Jun 2007 12:28 GMT
"Asif" <asifhashmani@hotmail.com> wrote in message
<1183110599.248444.316170@k29g2000hsd.googlegroups.com>:
> Hi all
>
[quoted text clipped - 40 lines]
>
> Thanks
Another way of testing whether a selction is made, is to test the
.ListIndex property, where a return value of -1 indicates no
selection
If Me!lstMyList.ListIndex = -1 Then
' no selection
Else
' something is selected
End If

Signature
Roy-Vidar