Results 1 to 6 of 6
  1. #1
    ther is offline Novice
    Windows 7 64bit Access 2003
    Join Date
    Jun 2011
    Posts
    3

    Combo boxes and field updating (Newbie)

    Hi all,



    I'm pretty new with access and i have a question.

    I have a combo box that picks up 4 separate pieces of data from a table with several bits of info : St number, st name, suburb & postcode... now once the user selects an address, i want that info selected to populate on a separate table and on text boxes within the form.

    So far i have been able to populate teh data into the text boxes but i'm not sure as to how i can then populte that data into Table 2.

    Table 1 contains data ranging contains addresses segmented by street number, name, suburb, etc plus other info.
    Table 2 has similar columns that need to be populated by whatever was chosen in the combo box.

    Any help would be greatly appreciated.

    Cristian

  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,640
    Note the caution against saving it, and the method below if appropriate.

    http://www.baldyweb.com/Autofill.htm
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    Rod is offline Expert
    Windows Vista Access 2007
    Join Date
    Jun 2011
    Location
    Metro Manila, Philippines
    Posts
    679
    If your text boxes are bound to Table2 then the table will be updated automatically.

    What do I mean by bound?

    The best thing is for you to look at some of the properties in the Property Window in Design View of the form. First select the form and under the Data tab in the Property Window see whether there is an entry against Record Source. If there is, what is it? It could be a table name, a query name or an SQL statement. If Table 2 is involved in any way then you're halfway there.

    Now select each text box in turn and, still under the Data tab, see if there is an entry against Control Source. Any entry is usually the name of a table column. Hopefully your control sources are the names of corresponding columns in Table 2.




    What if either or both of these bindings are missing? Well you have two options:
    1. Put the appropriate values in the Record Source and Control Source properties such that the form and the text box controls become bound to Table 2. Access will now handle the updates for you.
    2. Select a suitable point in the user dialog - usually an event - and push the new values into Table 2 via code, either Macro (if feasible) or VBA.
    Don't ask me for a Macro solution; the last time I coded a Macro was more than twenty years ago.

    The VBA code will look something like the following.

    Code:
     
    Dim rstTable2 as DAO.Recordset
    Set rstTable2 = CurrentDb.OpenRecordset("Table 2", dbOpenTable)
    With rstTable2
    .AddNew
    !TableField1 = Me.txtField1
    !TableField2 = Me.txtField2
    ...
    .Update
    End With
    rstTable2.Close
    set rstTable2 = nothing
    You have to substitute your own names for Table 2, TableField1, txtField1, etc.

  4. #4
    ther is offline Novice
    Windows 7 64bit Access 2003
    Join Date
    Jun 2011
    Posts
    3
    Thank you very much!!!

  5. #5
    ther is offline Novice
    Windows 7 64bit Access 2003
    Join Date
    Jun 2011
    Posts
    3

    Smile

    Quote Originally Posted by pbaldy View Post
    Note the caution against saving it, and the method below if appropriate.

    http://www.baldyweb.com/Autofill.htm

    this worked exactly how i need it to work..

  6. #6
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,640
    Happy to help!
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Replies: 9
    Last Post: 06-04-2014, 10:45 AM
  2. Combo box for newbie
    By Mrcams in forum Access
    Replies: 3
    Last Post: 12-05-2010, 10:14 AM
  3. Updating a Combo Box
    By DaughanP in forum Forms
    Replies: 3
    Last Post: 12-04-2009, 08:52 AM
  4. new problem: Updating Combo box
    By ali-gagi in forum Forms
    Replies: 4
    Last Post: 07-06-2009, 07:29 PM
  5. combo not updating form
    By cjamps in forum Forms
    Replies: 5
    Last Post: 04-14-2009, 12:00 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