S
Steve
Greetings:
I am using the following code to allow a user to display a particular record
by clicking a particular record in a listbox.
Private Sub lbxProblem_AfterUpdate()
' Find the record that matches the control.
Dim rs As Object
Set rs = Forms!frmMaster!.Recordset.Clone
rs.FindFirst "[intProblemID] = " & Str(Nz(Me![lbxProblem], 0))
If Not rs.EOF Then Forms!frmMaster!fsubOpen!fsubHPI.Form.Bookmark =
rs.Bookmark
End Sub
This code works fine so long as there is a matching record. But it can be
that lbxProblem contains records that are not present in
"Forms!frmMaster!.Recordset.Clone".
In that case, I would think that the phrase "if not rs.EOF" would evaluate
to false, or in other words rs.EOF would be true but this does not appear to
be the case. Even when the intProblemID is not in the RecordsetClone,
"Forms!frmMaster!fsubOpen!fsubHPI.Form.Bookmark" still runs.
I would like to be able to put code in as follows:
If rs.EOF = true then 'intProblemID does not exist in current recordset
' do something
End if
but again even when intProblemID does not exist in the record set rs.EOF
still is considered false and the 'do something part of the code does not
run. What am I missing here? Thanks for any help.
I am using the following code to allow a user to display a particular record
by clicking a particular record in a listbox.
Private Sub lbxProblem_AfterUpdate()
' Find the record that matches the control.
Dim rs As Object
Set rs = Forms!frmMaster!.Recordset.Clone
rs.FindFirst "[intProblemID] = " & Str(Nz(Me![lbxProblem], 0))
If Not rs.EOF Then Forms!frmMaster!fsubOpen!fsubHPI.Form.Bookmark =
rs.Bookmark
End Sub
This code works fine so long as there is a matching record. But it can be
that lbxProblem contains records that are not present in
"Forms!frmMaster!.Recordset.Clone".
In that case, I would think that the phrase "if not rs.EOF" would evaluate
to false, or in other words rs.EOF would be true but this does not appear to
be the case. Even when the intProblemID is not in the RecordsetClone,
"Forms!frmMaster!fsubOpen!fsubHPI.Form.Bookmark" still runs.
I would like to be able to put code in as follows:
If rs.EOF = true then 'intProblemID does not exist in current recordset
' do something
End if
but again even when intProblemID does not exist in the record set rs.EOF
still is considered false and the 'do something part of the code does not
run. What am I missing here? Thanks for any help.