Results 1 to 2 of 2
  1. #1
    Zipster1967 is offline Novice
    Windows 7 64bit Access 2003
    Join Date
    May 2006
    Location
    Wisconsin
    Posts
    19

    Being able to enter new information in a lookup field

    I am not sure I am stating this right but I want to be able to enter information in an inventory database I have created but do not yet have all the categories entered into the category table. I would like to be able to add new categories in the data entry form and have it update the category table with the new categories. The same thing with sub-categories, sections, Areas, and shelves. (This is a shop inventory database to be able to locate everything in the shop without having to look through a bunch of different containers. Is there an easy way to do this without having to go into VBA code or macros? (Not fluent in macro programming yet.) I will try and give all the information I have in the database already and see if I am on the right track here.
    Tables: Contain:
    Categories Woodworking,Automotive,Chemicals,etc...
    ShopInventory item information with links to all other tables
    Sections Areas of shop (Quadrants)
    Shelves Shelving unit name
    Containers If item is in a container like a toolbox, plastic tub, cardboard box
    Levels Shelf number item is on 1 to 7 for most shelving units
    ContainerTypes Container types set as Cardboard box, plastic tub, compartmentalized case, etc...
    Fields in each table:
    ShopInventory:
    1.ItemID Numeric autonumber
    2.CategoryID Lookup to categories table
    3.SectionID Lookup to Sections table
    4.ShelfID Lookup to Shelves table
    5.ItemName Name of item
    6.ItemDesc Detailed description of item
    7.PurchaseDate Date purchased
    8.LevelNumber Lookup to Levels table
    9.ContainerName Lookup to Containers table

    What I am trying to create is a form that I can enter new items into that will list all the categories in a dropdown box but allow entry of new category if it doesn;t already exist. Same with the section, shelving unit, Level, containerName.

    The rest of the table are very simple.
    Categories:
    1.CategoryID Autonumber
    2.CategoryName Entered Name for category
    Section:
    1.SectionID Autonumber
    2.SectionName Entered Name for section
    Shelves:
    1.ShelfunitID Autonumber
    2.ShelfUnitName Name of the shelving unit
    Levels:
    1.LevelID Autonumber
    2.LevelName Entered name of shelf or floor or wall or ceiling
    Containers:
    1.ContainerID Autonumber


    2,ContainerName entered name of container
    3.Containertype Lookup to containertype table
    Containertype:
    1.COntainerTypeID Autonumber
    2.ContainerTypeName entered as cardboard Box, Plastic Tub, Compartmentalized case, etc.

    I hope that isn;'t too confusing. Any help in structure hints or how I should go about getting the form built would be great. Or any pointers on where to get the instructions for how to do this online would be great.

  2. #2
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows XP Access 2003
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,544
    Hi Zipster1967

    Adding items to tables from an entry in a list box can be done, but I don't know of any way to do it without using VBA.

    You would need code in the "Not In List" event of the combo box.
    It is not hard to do if you have some knowledge of VBA coding.

    Below is some code that I have used to add a new category to one of my tables (called "tblCat"). It should be quite simple to make the changes required for you to be able to use it.
    If you want to use it, you're welcome
    If you need some more help, post back there are plenty of people here that are able to help.
    Code:
     
    Private Sub CatID_NotInList(NewData As String, Response As Integer)
    On Error GoTo Err_CatID_NotInList_Error
    Dim rec As DAO.Recordset
     
    NewData = StrConv(NewData, vbProperCase)
    If MsgBox("Add '" & NewData & "' to the list?", vbQuestion + vbYesNo + vbDefaultButton2, "Confirmation Required") = vbYes Then
    Set rec = CurrentDb.OpenRecordset("tblCat")
    With rec
    .AddNew
    .Fields("Category") = NewData
    .Update
    End With
    Set rec = Nothing
    Response = acDataErrAdded
    Else
    Response = acDataErrContinue
    End If
    Exit_ErrorHandler:
    Exit Sub
    Err_CatID_NotInList_Error:
    MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure CatID_NotInList of VBA Document Form_frmSalesDet at Line " & Erl
    Resume Exit_ErrorHandler
    End Sub
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

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

Similar Threads

  1. Default Information for an existing field HELP
    By opinionsrfun in forum Access
    Replies: 1
    Last Post: 06-19-2013, 06:30 AM
  2. Replies: 2
    Last Post: 05-06-2011, 02:00 PM
  3. Use a lookup field to influence values in another field
    By nathanrt in forum Database Design
    Replies: 3
    Last Post: 01-13-2011, 03:40 PM
  4. Replies: 3
    Last Post: 02-17-2010, 02:29 PM
  5. Replies: 1
    Last Post: 07-06-2007, 08:27 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