help me please

icemonster

Registered User.
Local time
Today, 15:25
Joined
Jan 30, 2010
Messages
502
here's my code, i copied it off from a sample database a long time ago, now my thing is, when i click the listbox, it would query the records selected, but what if my listbox has records that are null? how do i add the line to the code?

PHP:
Private Sub lstSchedule_Click()
DoCmd.Requery
Me.RecordsetClone.FindFirst "[SCHEDULEID] = " & Me![lstSchedule] & ""
    If Not Me.RecordsetClone.NoMatch Then
        Me.Bookmark = Me.RecordsetClone.Bookmark
    Else
        MsgBox "Could not locate [" & Me![lstSchedule] & "]"
    End If
End Sub
 
Add in a test to see if a selection has been made from the listbox.
I see that your listbox is operating in single select mode (and not multi select mode) so we can use the IsNull check.

Private Sub lstSchedule_Click()

If Not IsNull(Me.lstSchedule) Then
DoCmd.Requery
Me.RecordsetClone.FindFirst "[SCHEDULEID] = " & Me![lstSchedule] & ""
If Not Me.RecordsetClone.NoMatch Then
Me.Bookmark = Me.RecordsetClone.Bookmark
Else
MsgBox "Could not locate [" & Me![lstSchedule] & "]"
End If
End If
End Sub
 
thanks. works now :P
 

Users who are viewing this thread

Back
Top Bottom