Syntax Help

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

You want to search only in the "ID" field? Try setting the focus to
that field first:

Dim varIDField As Variant
varIDField = Me.txtID

Me.ID.SetFocus

DoCmd.FindRecord strIDField, _
acAnywhere, , _
acSearchAll, , acCurrent
 
thanks much that did the trick

-----Original Message-----


You want to search only in the "ID" field? Try setting the focus to
that field first:

Dim varIDField As Variant
varIDField = Me.txtID

Me.ID.SetFocus

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


--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)


.
 
Dirk,

I thought setting the focus would do the trick; but no
luck...

Now I'm getting a compile error "Method or data member not
found."

'code

Dim strIDField As Variant
strIDField = Me.txtID

Me.ID.SetFocus
DoCmd.FindRecord strIDField, acAnywhere, ,
acSearchAll, , acCurrent


Can setfocus work with Me?

DAvid
 
Dirk,

I thought setting the focus would do the trick; but no
luck...

Now I'm getting a compile error "Method or data member not
found."

'code

Dim strIDField As Variant
strIDField = Me.txtID

Me.ID.SetFocus
DoCmd.FindRecord strIDField, acAnywhere, ,
acSearchAll, , acCurrent


Can setfocus work with Me?

Absolutely. Check that the name of the control is actually "ID"; you
have to use the name of the control, not the field to which it's bound.
I'm assuming also that this code is executing in the code module of the
form containing the control. If it's someplace else, the reference to
"Me" won't work.
 
Back
Top