Requery and return to last record on continuous form error

A

Anne

I found this post from 08/28/09 in which FredG supplied this code, I replaced
ID with my MyTransID which is my autonumberfield and primaryID key for this
query from tbltransactions.

Private Sub cmdRefresh_Click()
Dim MyId As Long
MyId = Me.MyTransID
Me.Requery
Me.MyTransID.SetFocus
DoCmd.FindRecord MyId, acEntire, , acSearchAll, , acCurrent
End Sub

I get an error and highlighted is SetFocus.
 
P

Pendragon

It's possible that the name of the field on your form is not necessarily
MyTransID. In design view on the properties view for your field, go to the
Other tab and see what is in the Name field. It could be something like
Text04. That's what you need to put in your reference.

As you have it, you are referring to the field name as it is in the
table/query, not as it may be on the form. If you want to have meaningful
names for fields on your form, try using a prefix such as "txt" for text
boxes, "cbo" for combo boxes, etc etc., so your form field name might be
txtMyTransID.
 
A

Anne

That was it. Thanks,

Pendragon said:
It's possible that the name of the field on your form is not necessarily
MyTransID. In design view on the properties view for your field, go to the
Other tab and see what is in the Name field. It could be something like
Text04. That's what you need to put in your reference.

As you have it, you are referring to the field name as it is in the
table/query, not as it may be on the form. If you want to have meaningful
names for fields on your form, try using a prefix such as "txt" for text
boxes, "cbo" for combo boxes, etc etc., so your form field name might be
txtMyTransID.
 

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

Top