Results 1 to 5 of 5
  1. #1
    shenix2005 is offline Novice
    Windows XP Access 2007
    Join Date
    Aug 2010
    Posts
    8

    using list box to append whole table


    i have two tables named "item master" &"item set" in item master there are text feilds like id1,id2,id3..etc.same feilds in other table also where as it can store three values of all these feilds.
    now i have made a list box with the contents of "item master" in a form.
    if user selects one item say itm1 in the list box,it should append all the feilds of itm1 (id1,id2,id3)to the corresponding feilds of table "item set",and after that append it should again ready for next selection and record the whole feild data of second selection to the next feilds of table item "set".three selections like this to be performed
    how is this possible?

  2. #2
    maximus's Avatar
    maximus is offline Expert
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Aug 2009
    Location
    India
    Posts
    931
    I have tried to replicate a situation very similar to yours. I have two tables Table3 and Table 4

    Table3 has Fields ID, Id1, Id2, Id3

    Table4 too has Id1, Id2, Id3

    I have used a unbound form created a List box with RowSource Table3. This will give me a list of all items in Table3.

    Then I have a command button with the codes:

    here I have used SQL to insert data. I have used List.Column property to get the values. The List Box will have four Columns with the the index as:

    ID=0
    Id1=1
    Id2=2
    Id3=3

    Dim strSQL As String
    strSQL = "Insert into Table4(id1,id2,id3) Values('" & Me.List0.Column(1) & "','" & Me.List0.Column(2) & "','" & Me.List0.Column(3) & "');"
    MsgBox strSQL
    CurrentDb.Execute strSQL, dbFailOnError

    U can also use a RecordSet to do the same thing


    Set rs = CurrentDb.OpenRecordset("Table4")
    rs.AddNew
    rs!id1 = Me.List0.Column(1)
    rs!ID2 = Me.List0.Column(2)
    rs!id3 = Me.List0.Column(3)
    rs.Update
    rs.Close
    Set rs = Nothing

    let me know if this solves your problem. if it does please mark the thread solved.

  3. #3
    shenix2005 is offline Novice
    Windows XP Access 2007
    Join Date
    Aug 2010
    Posts
    8
    ye,it works,but when ever i load the form it creates a blank record in the table.even i have not selected an item in the list box.
    i have used the code in listbox's on enter property as i required that for fast data entry.

  4. #4
    maximus's Avatar
    maximus is offline Expert
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Aug 2009
    Location
    India
    Posts
    931
    Better have the Code on the onclick event of a Command Button. Let the User Select an Item from the list box and then click the Command Button. Oncl

  5. #5
    shenix2005 is offline Novice
    Windows XP Access 2007
    Join Date
    Aug 2010
    Posts
    8
    Quote Originally Posted by maximus View Post
    Better have the Code on the onclick event of a Command Button. Let the User Select an Item from the list box and then click the Command Button. Oncl

    Thanks Dear It Solved my Issue...

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

Similar Threads

  1. Master list table with changing values.
    By evander in forum Database Design
    Replies: 11
    Last Post: 06-24-2010, 07:40 AM
  2. Loop through a list of table names and compare
    By mikneus in forum Programming
    Replies: 1
    Last Post: 05-21-2010, 10:36 AM
  3. Append query won't append
    By yelkenli in forum Queries
    Replies: 5
    Last Post: 02-12-2010, 11:19 AM
  4. Highlighting Items in List Box from Table Data
    By swalsh84 in forum Programming
    Replies: 2
    Last Post: 01-25-2010, 08:55 AM
  5. saving a list box to access table
    By newguy357 in forum Forms
    Replies: 0
    Last Post: 05-05-2006, 12:22 PM

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