Syntax for Find Record

  • Thread starter Thread starter David Hunt
  • Start date Start date
D

David Hunt

Within a form I have an unbound text box which I 've
named "txtID". I want to use it to do a search.

I want to take the value from this form and run a find
record command. I think I'm screwing up because I'm not
specifying the current field first? The field I wish to
search is called "ID"

should I be doing acCurrent=me.id ????

The error I'm getting is that "A macro set to one of the
current fields properties failed because of an error in a
FindRecord action argument"

Please help?

' Code below

Dim strIDField As Variant
strIDField = Me.txtID

DoCmd.FindRecord strIDField, acAnywhere, ,
acSearchAll, , acCurrent

' End Code

David Hunt
 
David said:
Within a form I have an unbound text box which I 've
named "txtID". I want to use it to do a search.

I want to take the value from this form and run a find
record command. I think I'm screwing up because I'm not
specifying the current field first? The field I wish to
search is called "ID"

should I be doing acCurrent=me.id ????

The error I'm getting is that "A macro set to one of the
current fields properties failed because of an error in a
FindRecord action argument"

Please help?

' Code below

Dim strIDField As Variant
strIDField = Me.txtID

DoCmd.FindRecord strIDField, acAnywhere, ,
acSearchAll, , acCurrent

I don't use the DoCmd stuff if I can find another way, so I
can't answer your question. But, here's how I do that kind
of thing:

If Not IsNull(Me.txtID) Then
With Me.RecordsetClone
.FindFirst "ID = " & Me.txtID
If Not .NoMatch Then Me.Bookmark = .Bookmark
End With
End If
 
David Hunt said:
Within a form I have an unbound text box which I 've
named "txtID". I want to use it to do a search.

I want to take the value from this form and run a find
record command. I think I'm screwing up because I'm not
specifying the current field first? The field I wish to
search is called "ID"

should I be doing acCurrent=me.id ????

The error I'm getting is that "A macro set to one of the
current fields properties failed because of an error in a
FindRecord action argument"

Please help?

' Code below

Dim strIDField As Variant
strIDField = Me.txtID

DoCmd.FindRecord strIDField, acAnywhere, ,
acSearchAll, , acCurrent

' End Code

David Hunt

Answered in <microsoft.public.access.modulesdaovba>.
 
Back
Top