Results 1 to 4 of 4
  1. #1
    Silver Lounger GARYPSWANSON's Avatar
    Join Date
    Aug 2001
    Location
    Frederick, Maryland, USA
    Posts
    1,788
    Thanks
    0
    Thanked 2 Times in 2 Posts

    Add data to a table from a form.... (A2k SR1)

    A form contains a combobox. The combobox RowsourceType is a table. The table contains only one field, EquipmentType, and each value in the table is unique. The combobox Limit to List property is set to NO.

    The user inputs a value in the combo box that is not in the list (not in the table). The On Exit event of the combo box then runs some code that does the following:
    1. Check to see if the value entered is in the table. (Using a Dcount (.....) <> 1 to determine this)
    2. If the value is in the table (i.e., Dcount (...) = 1, do nothing....
    ** If the value is not in the table, (i.e,. Dcount(...) <> 1, then I want to update the table with the value that is currently in the combo box. (I.e., use a vbYesNo message box and the user would select yes when asked if the data should be added to the table.)

    I thought that I could write some code that would do this such as using an insert into statement, however, is it possible to use an insert into statement that gets its value from a form? I.e., Insert Into table xxx value from form.combobox.

    Any ideas on how I could do this. I figured that I could launch a form and have the user input the data in the form but this adds a step. I would rather have the data entered behind the scenes to eliminate the need to re-enter the data.

    If the user selects to add the data from the combo box to the table, what code could be used to do this? I am stumped.

    Any ideas?
    Regards,

    Gary
    (It's been a while!)

  2. #2
    Silver Lounger GARYPSWANSON's Avatar
    Join Date
    Aug 2001
    Location
    Frederick, Maryland, USA
    Posts
    1,788
    Thanks
    0
    Thanked 2 Times in 2 Posts

    Re: Add data to a table from a form.... (A2k SR1)

    As I was searching... I thinkg Post 159332 may answer my question.
    Regards,

    Gary
    (It's been a while!)

  3. #3
    5 Star Lounger
    Join Date
    Jul 2002
    Location
    Toronto, Ontario, Canada
    Posts
    1,139
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Add data to a table from a form.... (A2k SR1)

    Don't forget to change LimitToList to Yes.
    --
    Bryan Carbonnell - Toronto <img src=/S/flags/Ontario.gif border=0 alt=Ontario width=30 height=18> <img src=/S/flags/Canada.gif border=0 alt=Canada width=30 height=18>
    Unfortunately common sense isn't so common!!
    Visit my website for useful Word, Excel and Access code, templates and Add-Ins

  4. #4
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Add data to a table from a form.... (A2k SR1)

    You want the NotInList event and it will only work if you set Limit to List to Yes as Bryan suggested. There is sample code in the help files for the NotInList event but if you run into difficulties, post back and someone will help you out.
    Charlotte

Posting Permissions

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