Recordset problem

J

jhanby1

I am trying to navigate to a specific record in a recordset, which I
think is working, but I need the record to be displayed on a
subform(fsubCaseDetails) on my main form (frmMainPage). Below is the
code. Any ideas?

Private Sub cmdGoToCase_Click()
' Find the record that matches the control. If no match, display
message box.

Dim rs As Object

If IsNull(Me!txtGoToCase) = True Then
Msgbox "You must enter in a Case Number to search.", vbOKOnly,
"Missing Selection"
Else
Me.FilterOn = False
Set rs = Me.Recordset.Clone
rs.FindFirst "[CaseNumber] = '" & Me![txtGoToCase] & "'"

If rs.NoMatch = True Then
Msgbox "The number you entered, " & Me![txtGoToCase] & ",
is not a valid Case Number. " & _
"Please check the Case Number and try again.", vbOKOnly

Exit Sub
End If

If Not rs.EOF Then Me.Bookmark = rs.Bookmark
Me.txtGoToCase = ""
End If
End Sub
 
M

Marshall Barton

I am trying to navigate to a specific record in a recordset, which I
think is working, but I need the record to be displayed on a
subform(fsubCaseDetails) on my main form (frmMainPage). Below is the
code. Any ideas?

Private Sub cmdGoToCase_Click()
' Find the record that matches the control. If no match, display
message box.

Dim rs As Object

If IsNull(Me!txtGoToCase) = True Then
Msgbox "You must enter in a Case Number to search.", vbOKOnly,
"Missing Selection"
Else
Me.FilterOn = False
Set rs = Me.Recordset.Clone
rs.FindFirst "[CaseNumber] = '" & Me![txtGoToCase] & "'"

If rs.NoMatch = True Then
Msgbox "The number you entered, " & Me![txtGoToCase] & ",
is not a valid Case Number. " & _
"Please check the Case Number and try again.", vbOKOnly

Exit Sub
End If

If Not rs.EOF Then Me.Bookmark = rs.Bookmark
Me.txtGoToCase = ""
End If
End Sub


You need to operate on the subform's RecordsetClone to
navigate in the subform:

If IsNull(Me!txtGoToCase) = True Then
Msgbox "You must enter a Case Number to search.", _
vbOKOnly, "Missing Selection"
Else
With Me.subformcontrol.Form.RecordsetClone
.FindFirst "[CaseNumber] = '" & Me![txtGoToCase] & "'"
If .NoMatch = True Then
Msgbox "The number you entered, " & _
Me![txtGoToCase] & ", is not a valid Case Number. " _
& "Please check the Case Number and try again.", _
vbOKOnly

Exit Sub
Else
Me.Bookmark = .Bookmark
Me.txtGoToCase = ""
End If
End With
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

Similar Threads


Top