Syntax Help

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

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
 
G

Guest

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)


.
 
G

Guest

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
 
D

Dirk Goldgar

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.
 

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