D
DS
I'm trying to run this code on the main form load event.
If the Subform has no records then the Listbox on the subform is empty
otherwisw populate the listbox with the appropriate records. It works
fine whenever there are records but when I open the main form with a new
record all of the records show in the listbox. The DCount always seems
to show how many records are there, disregarding my criteria. Any help
appreciated.
Thanks
DS
Private Sub Form_Load()
Me.Text307 = DCount("SalesID", "SalesDetails", "SalesID =
Forms!Buttons!SalesID")
If Me.Text307 = Null Then
End
Else
With Forms!Buttons.PrepSlipSub.Form!List52
.RowSource = "SELECT
LineID,ItemID,SalesID,Expr8,Expr7,Expr6,Quantity,Expr5,Expr4,ItemType" _
& " FROM PrepSlipQ " _
& " WHERE SalesID = " & Forms!Buttons.PrepSlipSub.Form!SalesID
& "" _
& " ORDER BY LineID,ItemType ASC;"
Forms!Buttons.PrepSlipSub.Form!List52.Requery
End With
End If
End Sub
If the Subform has no records then the Listbox on the subform is empty
otherwisw populate the listbox with the appropriate records. It works
fine whenever there are records but when I open the main form with a new
record all of the records show in the listbox. The DCount always seems
to show how many records are there, disregarding my criteria. Any help
appreciated.
Thanks
DS
Private Sub Form_Load()
Me.Text307 = DCount("SalesID", "SalesDetails", "SalesID =
Forms!Buttons!SalesID")
If Me.Text307 = Null Then
End
Else
With Forms!Buttons.PrepSlipSub.Form!List52
.RowSource = "SELECT
LineID,ItemID,SalesID,Expr8,Expr7,Expr6,Quantity,Expr5,Expr4,ItemType" _
& " FROM PrepSlipQ " _
& " WHERE SalesID = " & Forms!Buttons.PrepSlipSub.Form!SalesID
& "" _
& " ORDER BY LineID,ItemType ASC;"
Forms!Buttons.PrepSlipSub.Form!List52.Requery
End With
End If
End Sub