Syntax for Find Record

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
 
M

Marshall Barton

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
 
D

Dirk Goldgar

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>.
 

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

Syntax Help 5
FindRecord Error 2
Problem with Tree View 2
Find Button 1
Access 2007 selecting record 2
How specify "currrent field" for DoCmd.FindRecord ? 1
Find record in a listbox 1
On Open form go to record 1

Top