Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DoCmd.GoToRecord - help with correct syntax

Status
Not open for further replies.

kgreen

Technical User
Sep 11, 2000
32
GB
I am having problems refering to a field or control on a subform.

What I am trying to do is this:
I have a main form called [FrmItems] and 2 subforms [SubFrm1] & [SubFrm2]. Both sub forms are displayed as datasheets and on [SubFrm1] is a field or control called [ItemID]. I also have a button on the *MAIN* form that the user, (after first selecting a record in [Subfrm1]), clicks and this then runs a query.

I then want access to move to the next record in [SubFrm1] after this query has run. I have tried various combinations of refering to the [ItemID] but none of them seem to work. I keep getting error messages.

Am i doing something wrong please.

This is the two lines of code that I have after the RunQuery code:

DoCmd.GoToControl Forms!FrmItems!SubFrm1.Form = ItemID
DoCmd.GoToRecord , ItemID, acNext

Can someone help me please as I am totally stuck.

Thank you,

Kenny [sig][/sig]
 
Replace your code below with the new code listed.

Old code
DoCmd.GoToControl Forms!FrmItems!SubFrm1.Form = ItemID
DoCmd.GoToRecord , ItemID, acNext

New code
Me.SubForm1.SetFocus
DoCmd.GoToRecord acActiveDataObject, , acNext

Let me know if this works for you. I tried it on my form and it works.

[sig]<p>John A. Gilman<br><a href=mailto:gms@uslink.net>gms@uslink.net</a><br>[/sig]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top