Results 1 to 9 of 9
  1. #1
    Xterra14s is offline Advanced Beginner
    Windows 10 Access 2013 64bit
    Join Date
    May 2016
    Posts
    32

    Record not clearing?

    This is the code I have:
    Private Sub Command0_Click()
    [Forms]![DME Database]!MainFormMachines.SetFocus
    [Forms]![DME Database]!MainFormMachines = [Forms]![DME Database]![Machines Hidden]
    [Forms]![DME Database]!MainFormSupplies.SetFocus
    [Forms]![DME Database]!MainFormSupplies = [Forms]![DME Database]![Supplies Hidden]
    [Forms]![DME Database]![NavigationSubform]![Order input form].SetFocus
    [Forms]![DME Database]![NavigationSubform].[Form]![Order input form]!ID.SetFocus
    DoCmd.GoToRecord , , acNewRec
    MsgBox (" Order Submitted! ")
    DoCmd.OpenForm "PA2_Form"
    End Sub



    Everything is working fine except the DoCmd.GoToRecord , , acNewRec. The record wont clear to go to the next. Any idea why its doing this?

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    First thing I would do is fill in the missing arguments to specify the form. By the way, you don't have to set focus to a control to give it a value.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    Xterra14s is offline Advanced Beginner
    Windows 10 Access 2013 64bit
    Join Date
    May 2016
    Posts
    32
    do you mean in this part: DoCmd.GoToRecord , , acNewRec

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    Yes, if you look in help on GoToRecord, you've skipped 2 arguments.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    Xterra14s is offline Advanced Beginner
    Windows 10 Access 2013 64bit
    Join Date
    May 2016
    Posts
    32
    [Forms]![DME Database]![NavigationSubform]![Order input form].DoCmd.GoToRecord , , acNewRec

    Would that be more appropriate?

  6. #6
    Xterra14s is offline Advanced Beginner
    Windows 10 Access 2013 64bit
    Join Date
    May 2016
    Posts
    32
    Private Sub Command0_Click()
    [Forms]![DME Database]!MainFormMachines.SetFocus
    [Forms]![DME Database]!MainFormMachines = [Forms]![DME Database]![Machines Hidden]
    [Forms]![DME Database]!MainFormSupplies.SetFocus
    [Forms]![DME Database]!MainFormSupplies = [Forms]![DME Database]![Supplies Hidden]
    [Forms]![DME Database]![NavigationSubform]![Order Input form].SetFocus
    [Forms]![DME Database]![NavigationSubform].[Form]![Order Input form]!ID.SetFocus
    [Forms]![DME Database]![NavigationSubform].[Form]![Order Input form].DoCmd.GoToRecord , , acNewRec
    MsgBox (" Order Submitted! ")
    DoCmd.OpenForm "PA2_Form"

    I wrote it out this way but am still having the same issue.

  7. #7
    John_G is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2011
    Location
    Ottawa, ON (area)
    Posts
    2,615
    Can you clarify on which form you want to move to a new record? It looks like it is the subform [Order input form] - correct?

    If that form is not going to a new record, check the setting for its "Allow Additions" property - it should be "Yes"

    Are you getting any error messages in this process?

  8. #8
    Xterra14s is offline Advanced Beginner
    Windows 10 Access 2013 64bit
    Join Date
    May 2016
    Posts
    32
    That is the correct form and I do have allow additions set to yes. The error sates : Run time error '2498' An an expression you entered is the wrong data type for one of the arguements.
    I was recommended to set up that line like this:
    DoCmd.GoToRecord , [Forms]![DME Database]![NavigationSubform].[Form]![Order Input form], acNewRec

  9. #9
    John_G is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2011
    Location
    Ottawa, ON (area)
    Posts
    2,615
    The second argument is the problem - the command is expecting a Text String containing the name of an object (check the help file for details).

    What you can do is set the focus to the sub-form, and then go to a new record:

    [Forms]![DME Database]![NavigationSubform]![Order Input form].SetFocus
    DoCmd.gotorecord ,,acNewRec

    By leaving the first two arguments blank, the command uses the current object, which is the input order form.
    Last edited by John_G; 08-15-2016 at 09:42 AM. Reason: clarification

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

Similar Threads

  1. Is clearing a form the same as adding a new record?
    By Access_Novice in forum Forms
    Replies: 2
    Last Post: 12-04-2013, 08:15 PM
  2. Clearing Fields for on User Form for New Record
    By dccjr in forum Programming
    Replies: 1
    Last Post: 01-31-2013, 06:40 PM
  3. Clearing Combo Box when adding a new record
    By Purdue_Engineer in forum Forms
    Replies: 3
    Last Post: 09-25-2012, 12:57 PM
  4. Clearing Checkbox on New Record
    By rossi45 in forum Programming
    Replies: 5
    Last Post: 04-16-2012, 05:30 PM
  5. Clearing certain boxes on form for next record using VB
    By justinwright in forum Programming
    Replies: 3
    Last Post: 07-21-2010, 12:16 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