Results 1 to 9 of 9
  1. #1
    Join Date
    Feb 2009
    Posts
    29

    Unanswered: NEW button problems

    I have a query that searches my customer table to look for existing customers. The results of the query are displayed in a split form where you can choose which customer you are looking for. There are 3 buttons on this form: HOME takes you back to the main menu, GO TO opens the Customer form to the matching ID, and NEW is supposed to open the Customer form to a new record. It's not. Clicking NEW opens the Customer form, but I get an error message saying that it could not go to the specified record. This is the code I am using:

    DoCmd.OpenForm "frmCustomer"
    DoCmd.GoToRecord , "", acNewRec

    The GO TO button looks like this:

    DoCmd.OpenForm "frmCustomer", , , "ID=" & Me.ctrCustId

    Where is my mistake with the NEW button?

  2. #2
    Join Date
    Nov 2007
    Location
    Adelaide, South Australia
    Posts
    4,049
    Well, I would go with DoCmd.OpenForm "frmCustomer", , , "ID=0"

    Not sure why I do it this way, but this is what I have been doing for years to open a form to a new record for data entry.
    Owner and Manager of
    CypherBYTE, Microsoft Access Development Specialists.
    Microsoft Access MCP.
    And all around nice guy!


    "Heck it's something understood by accountants ... so it can't be 'that' difficult..." -- Healdem
    "...teach a man to code and he'll be frustrated for life! " -- georgev

  3. #3
    Join Date
    Oct 2004
    Location
    Melbourne, Australia
    Posts
    201
    Perhaps the system parameter is not the best.

    This works for me when creating a new record:

    DoCmd.OpenForm "<form name>", , , , acFormAdd

  4. #4
    Join Date
    Feb 2009
    Posts
    29
    Thank you both for your suggestions. However, after trying both of them, neither of them work. Both open the correct form, however it is blank, there are no fields to fill in. The subform is not there, the buttons are not there, nothing. What am I missing?

  5. #5
    Join Date
    Aug 2003
    Location
    Bulgaria, Plovdiv
    Posts
    36

    GoTo

    On Error Resume Next
    DoCmd.GoToRecord , , acGoTo, "ID=" & 234
    On Error GoTo 0

  6. #6
    Join Date
    Nov 2007
    Location
    Adelaide, South Australia
    Posts
    4,049
    Make sure the form has its Allow Additions property switched on?
    Owner and Manager of
    CypherBYTE, Microsoft Access Development Specialists.
    Microsoft Access MCP.
    And all around nice guy!


    "Heck it's something understood by accountants ... so it can't be 'that' difficult..." -- Healdem
    "...teach a man to code and he'll be frustrated for life! " -- georgev

  7. #7
    Join Date
    Nov 2007
    Location
    Adelaide, South Australia
    Posts
    4,049
    Can you look at the recordset for the query and see the new record as a normal table shows?

    Either one of these would generate your problem.
    Owner and Manager of
    CypherBYTE, Microsoft Access Development Specialists.
    Microsoft Access MCP.
    And all around nice guy!


    "Heck it's something understood by accountants ... so it can't be 'that' difficult..." -- Healdem
    "...teach a man to code and he'll be frustrated for life! " -- georgev

  8. #8
    Join Date
    Feb 2009
    Posts
    29
    I'm not sure what I did, but everything works now. Thanks!

  9. #9
    Join Date
    Nov 2007
    Location
    Adelaide, South Australia
    Posts
    4,049
    Awesome, well done
    Owner and Manager of
    CypherBYTE, Microsoft Access Development Specialists.
    Microsoft Access MCP.
    And all around nice guy!


    "Heck it's something understood by accountants ... so it can't be 'that' difficult..." -- Healdem
    "...teach a man to code and he'll be frustrated for life! " -- georgev

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •