Results 1 to 7 of 7
  1. #1
    crimedog is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Dec 2013
    Posts
    141

    Add Customer Name into Customer Table each time a Unique Customer added to SaleTable

    I have a Table Sales - that lists customer and order information
    Most of the customers are new - is there a way to populate Customer Name Table with a new entry each time a new customer is input into the Sales Tale
    (Without having to add the custome to Customer Name Table - then going to Sales Order)
    OR
    Failing that - is there a way to use a list box that points to Customer Name Table (and if it doesn't find the one you want, will allow you toadd a new record) In the SAME form as you use to add to Sales Table.
    so:
    Date (textbox linking to form.Sales) Customer Name (List Box linking to form.CustomerName + adding the info to form.Sale)

    Thanks

  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,521
    Search here on "notinlist", which is a commonly used method to add new items to a table underlying a combo row source.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,899
    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.

  4. #4
    crimedog is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Dec 2013
    Posts
    141
    Ok I found those tutorials helpful - And thought I was understanding it.
    I have my 1 to many relationship, the Combobox set to the CustomerName on CustomerT... The Event NotINList set to go off. I thought I had pretty good code. But when I test it, nothing happens when I enter NewItem into Combo Box, until I go to next record, where it tells me I can't enter it because of the One to Many relationship.

    If you could Check out the CboCustomerName on OrderRegisterF. (which is actually on a subform) See if the VBA code is wrong.

    I don't even get the initial msgBox
    Attached Files Attached Files

  5. #5
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,899
    Change the combobox LimitToList property to Yes.

    Code:
    Private Sub CboCustomerName_NotInList(NewData As String, Response As Integer)
        Answer = MsgBox("Do you want to add " & NewData & _
            " to Customer List?", vbYesNo, "Customer not found!")
        Response = acDataErrContinue
        Me.CboCustomerName = Null
        If Answer = vbYes Then
            CurrentDb.Execute "INSERT INTO CustomerT(CustomerName) Values('" & NewData & "')"
            Me.CboCustomerName.Requery
            Me.CboCustomerName = NewData
        End If
    End Sub
    Delete the code behind OrderRegister. It will error during Debug>Compile

    You are saving the company name not company ID. Is this what you want?

    Need to set subform Rep textbox Locked Yes, TabStop No or delete it.
    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.

  6. #6
    crimedog is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Dec 2013
    Posts
    141
    Works great - Why set the tabstop?

    Thanks for the help

  7. #7
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,899
    That's what I do for controls that don't need to get focus, one less keystroke for the users to get past.

    Really don't need that field in the subform at all.
    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.

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

Similar Threads

  1. customer form with notes from a linked table
    By dcorleto in forum Database Design
    Replies: 7
    Last Post: 01-05-2013, 03:20 PM
  2. Run Report For Each Customer
    By rivergum_23 in forum Queries
    Replies: 1
    Last Post: 04-29-2012, 12:53 PM
  3. Replies: 1
    Last Post: 12-24-2011, 08:48 AM
  4. Replies: 1
    Last Post: 10-26-2011, 05:13 AM
  5. Sorting by customer
    By eibooo in forum Queries
    Replies: 1
    Last Post: 05-25-2010, 12:00 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
  •  
Other Forums: Microsoft Office Forums