Results 1 to 9 of 9

button for adding a record

  1. #1
    ntambomvu is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Nov 2016
    Location
    Johannesburg south africa
    Posts
    83

    button for adding a record

    Hello Chaps,
    I am a newbie so please forgive the basic questions that i will be asking


    I have a table which has a combobox in the heading. the combo box is bound to
    the customer name field so that when I enter a name into the combobox the combobox displays all customer names that match the entry. clicking the desired name opens the record for that customer.
    Sometimes the requested name is not found meaning that this customer is not yet in the
    table.
    I would like to have a button to press that will then open a new blank record for me to capture the new record.
    my dilema is - can i put the button also into the heading so that as i scroll through the names I can just move the mouse pointer to the button , click the button and it must open the append function?
    please help??
    best regards

    fred

  2. #2
    davegri is online now Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    1,823
    Sure. Add the button to the heading and use the wizard for add new record.

  3. #3
    moke123's Avatar
    moke123 is offline Me.Dirty=True
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2012
    Posts
    244
    the combo box is bound to the customer name field
    Have you looked at the not in list event?

  4. #4
    Wayne is offline Novice
    Windows 10 Access 2016
    Join Date
    Apr 2019
    Location
    Toronto, Canada
    Posts
    2
    You can add a command button to your form, but you cannot put it into your combo box or drop-down list. Add a button to your form, name it btnAddNewRecord, and use this code:

    Code:
    Private Sub btnAddNewRecord_Click()
    
        On Error GoTo Err_btnAddNewRecord_Click
        
        'Open a new Order
        
        DoCmd.GoToRecord acDataForm, "YourFormName", acNewRec
        
        'Move to the first Control on the form
        
        DoCmd.GoToControl ("YourFieldName")
        
        'Add some error handling
    
    
    Exit_btnAddNewRecord_Click:
        Exit Sub
        
    Err_btnAddNewRecord_Click:
        MsgBox Err.Description, vbInformation, "Error"
        Resume Exit_btnAddNewRecord_Click
        
        End Sub
    Simply enter the form name you want opened, and the field name you want the cursor placed in (it will default to the first field if you don't use this part, but why take a chance)with the brackets and quotation marks.

    Wayne

  5. #5
    ntambomvu is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Nov 2016
    Location
    Johannesburg south africa
    Posts
    83
    Thanks wayne- I will try it tonight and let you know

    regards

    fred

  6. #6
    ntambomvu is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Nov 2016
    Location
    Johannesburg south africa
    Posts
    83
    Hello Wayne, much to my surprise -I have got it to work - thank you very much- but the cursor is located in the record specified and it wont let me enter anything in that field? it allows entries in other fields though? I have tried to find if the field is write-protected but it seems to be open it i look at the properties?
    any suggestions?
    thanks
    fred

  7. #7
    ntambomvu is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Nov 2016
    Location
    Johannesburg south africa
    Posts
    83
    dont worry - I found that the field was locked in the form !!
    progress !!!

  8. #8
    ntambomvu is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Nov 2016
    Location
    Johannesburg south africa
    Posts
    83
    hello wayne- part of my learning curve is to try and understand every word used. you use the following command ( or method ?)
    docmd .gotorecord acdataform blah blah
    what is acdataform? Is that an access word?
    many thanks

    fred

  9. #9
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    19,883
    Quote Originally Posted by ntambomvu View Post
    hello wayne- part of my learning curve is to try and understand every word used. you use the following command ( or method ?)
    docmd .gotorecord acdataform blah blah
    what is acdataform? Is that an access word?
    many thanks

    fred
    https://docs.microsoft.com/en-us/off...dataobjecttype
    Paul (wino moderator)
    MS Access MVP
    www.BaldyWeb.com

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

Similar Threads

  1. Replies: 7
    Last Post: 08-14-2018, 10:32 AM
  2. Replies: 3
    Last Post: 07-22-2018, 01:05 PM
  3. Adding a record will add a command button
    By NickWren in forum Programming
    Replies: 8
    Last Post: 04-04-2017, 06:11 PM
  4. Replies: 3
    Last Post: 10-02-2015, 06:58 PM
  5. Replies: 3
    Last Post: 10-28-2010, 06:02 AM

Posting Permissions

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