Requery and return to last record on continuous form error

  • Follow


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. 
0
Reply Utf 12/3/2009 10:34:06 PM

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.

"Anne" wrote:

> 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. 
0
Reply Utf 12/3/2009 10:44:01 PM


That was it. Thanks,

"Pendragon" wrote:

> 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.
> 
> "Anne" wrote:
> 
> > 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. 
0
Reply Utf 12/3/2009 10:54:01 PM

2 Replies
415 Views

(page loaded in 0.035 seconds)

Similiar Articles:
















7/17/2012 9:01:54 PM


Reply: