Results 1 to 6 of 6
  1. #1
    abusaif is offline Advanced Beginner
    Windows 7 32bit Access 2010 64bit
    Join Date
    Nov 2012
    Location
    Earth
    Posts
    39

    "DoCmd.GotoRecord" Help required

    Good Morning !



    I have a sub form and a button on a Main form. I want to set the button's behaviour to go to a new record on subform (which is a datasheet form), for such I tried a code like ;

    DoCmd.GoToRecord acDataForm, Me.frmMachineBasicSub.Form, acNewRec

    but it does not work.

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,602
    I always give subform container control a name different from the object it holds, like ctrBasic. Set focus to the container control then GoToRecord.

    Try:

    Me.ctrBasic.SetFocus
    DoCmd.GoToRecord , , acNewRec
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    abusaif is offline Advanced Beginner
    Windows 7 32bit Access 2010 64bit
    Join Date
    Nov 2012
    Location
    Earth
    Posts
    39
    Thanks Bro...
    It seems working but now debugger has moved to next line. Here is my complete code.

    dim ID as Long
    me.ctrBasic.setfocus
    DoCmd.GoToRecord , , acNewRec
    ID = me.ctrBasic.form.MachineID

    it stops at the red line of code where MachineID is a text field.

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,602
    Why do you have that line? It doesn't make sense to me.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    abusaif is offline Advanced Beginner
    Windows 7 32bit Access 2010 64bit
    Join Date
    Nov 2012
    Location
    Earth
    Posts
    39
    Ya June7 !

    My complete subroutine code is as follows, may it help you to understand. Actually, I want to copy current record.

  6. #6
    abusaif is offline Advanced Beginner
    Windows 7 32bit Access 2010 64bit
    Join Date
    Nov 2012
    Location
    Earth
    Posts
    39
    Private Sub btnCopy_Click()


    Dim ID As Long
    Me.frmMachineBasicSub.SetFocus
    DoCmd.GoToRecord , , acNewRec


    ID = me.frmMachineBasicSub.Form.MachineID


    Me.frmMachineBasicSub.Form.MGP.Value = DLookup("MGP", "tblMachineBasic", "MachineID = " & ID)


    Me.frmMachineBasicSub.Form.AssetNo.SetFocus


    End Sub

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 11
    Last Post: 03-29-2012, 02:32 PM
  2. Resetting a form having "Required" fields
    By hmushtaq in forum Forms
    Replies: 4
    Last Post: 04-19-2011, 08:24 AM
  3. docmd.SendKeys "{F9}" in 2007
    By RickM in forum Access
    Replies: 4
    Last Post: 09-10-2009, 09:13 AM
  4. "doCmd - can't find object"
    By drmcfall in forum Access
    Replies: 1
    Last Post: 08-18-2009, 09:41 PM
  5. Can I pass "sort by" using DoCmd.OpenReport
    By alsoto in forum Reports
    Replies: 3
    Last Post: 04-16-2009, 08:11 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums