list box issues

  • Thread starter Thread starter Dave
  • Start date Start date
D

Dave

On a customer order form I have a List Box that lists previous delivery
address for this customer (DB is for a flower shop).
Now when I go into order history I want to be able to pull up an old order
and show the address selected as it was when the order was placed.

This is the code I have to display an old order:
Private Sub Form_Current()
[Forms]![frmOrderEdit]![InvoiceNumber] =
[Forms]![frmOrdersList]![OrderID]
Dim VarLr As Variant
For Each VarLr In Me!DeliveryID.ItemsSelected
Me!DeliveryID.Selected(VarLr) = False
Next VarLr

If Forms![frmOrderEdit]![chkPickUp] = True Then
Me.txtCoverBig.Visible = True
Me.txtCoverSm.Visible = True
Me.txtPickUp.Visible = True
Me.lblDate.Caption = "PickUp Date:"
Me.lblTime.Caption = "PickUp Time:"
Me.DeliveryCharge.Value = "0.00"
Else
Me.txtCoverBig.Visible = False
Me.txtCoverSm.Visible = False
Me.txtPickUp.Visible = False
Me.lblDate.Caption = "Delivery Date:"
Me.lblTime.Caption = "Delivery Time:"
End If

End Sub

This code seems to work fine most of the time - however if there WAS NO
DELIVERY ADDRESS SELECTED (maybe a pick up order)- this code generated and
error pointing here:

Me!DeliveryID.Selected(VarLr) = False

How can I fix this error.

Any help here will be appreciated.

Thanks in advance
D
 
Hi Dave,

Not sure what you want exactly. If you want to skip the error, try insert
this line on top.

On Error Resume Next

Or

'-1 = True and 0 = False
If Me!DeliveryID.Selected(VarLr) = -1 Then 'if true process the loop
For Each VarLr In Me!DeliveryID.ItemsSelected
Me!DeliveryID.Selected(VarLr) = False
Next VarLr
End if
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top