Full Version: Find record from entered text box on sub form
UtterAccess Discussion Forums > Microsoft® Access > Access Forms
fritz
I'm trying to move to the correct record on a continuous form (ChitListSubF) which is located on an unbound parent form (BarF) by clicking a button which matches the numbers entered into a text box (Chittxt).

The button and text box are on the sub form. The user types the number into the textbox.

I get an "object doesn't support this property or method" error.

Can any see where the error is?

CODE
    With Forms!BarF.Form!ChitListSubF
      'find the first record that matches crieteria
     .RecordsetClone.FindFirst "[ChitNo] = '" & Me.Chittxt & "'"

      'if a matching record was found, then move to it
      If Not .RecordsetClone.NoMatch Then
         .Bookmark = .RecordsetClone.Bookmark
      End If
   End With


Harry
theDBguy
Hi Harry,

Try storing your recordset into a variable and then refer to it instead. For example:

Dim rs As Object
Set rs = Me.RecordsetClone
With rs
.FindFirst "ChitNo='" & Me.Chittxt & "'"
If Not .NoMatch Then
Me.Bookmark = .Bookmark
End If
End With
rs.Close
Set rs = Nothing

(untested)
Hope that helps...
fritz
Thanks, db, that did the trick! (plus reading my field names more carefully!crazy.gif)

For anyone else reading this, I learned the importance of the following

CODE
        
.FindFirst "ChiNo='" & Me.Chittxt & "'  [color="green"]   'only works if ChiNo is text - Me.Chittxt surrounded with single ' '[/color]

       vs

.FindFirst "[ChiNo] = " & CLng(Me.[Chittxt])  [color="green"] 'only works if ChiNo is number (no ' ' used) [/color]
theDBguy
You're welcome. Glad you were able to sort it out.

With regards to your field/control names, I assumed that Chittxt is a "text" because it had the "txt" in the name.

Good luck with your project.
fritz
Yes, that is correct (Chittxt is "text"). [ChiNo] however is Long ... which I forgot, sigh
H
theDBguy
I see... Thanks for the clarification. thumbup.gif
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.