Results 1 to 14 of 14
  1. #1
    JudyK is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Feb 2012
    Location
    Racine, WI
    Posts
    6

    Populate a table with info from a form

    I am a complete novice at Access - only know some basics.



    I have a form called Employees. On that form I have a combo box that lists our Building Locations [BldgLoc]. When a building location is selected, it populates the corresponding Street, City, info in the highlighted green box area. If a person is "Offsite" from one of the locations, I select "Offsite" from the BldgLoc combo box -- problem is, even though it gives me the right information, I need the information to fill in my Employe table field for "Street", etc.

    Thanks.

    Have tried many things, just don't get it.

  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,641
    If you want to save the data, you need the field as the control source, not a formula. See here:

    BaldyWeb - Autofill
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    JudyK is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Feb 2012
    Location
    Racine, WI
    Posts
    6
    IIf([cboBldgLoc]="Offsite",[Home Street],[cboBldgLoc].[column](1))

    So where in the formula above would i put my Control Source field called [Street]? The formula states that if the Blg Loc selected is "Offsite", then it should list the employees home street address. I just do not know where to make it fill in the control source of the table field called [Street].

    Thanks for the info from your web. I did try several of those options, but just stuck.

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,641
    Since you want to save the value in the table, you want the textbox control source to be just the field name, and incorporate your formula in this example from the link:

    Me.TextboxName = Me.ComboName.Column(2)
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    JudyK is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Feb 2012
    Location
    Racine, WI
    Posts
    6
    Can this be done without using VBA?

  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,641
    You could use a macro with SetValue I suppose. Because you want to save the value, you need some way to place the value into the bound textbox. The two methods are VBA and macros. The VBA is pretty simple.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  7. #7
    JudyK is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Feb 2012
    Location
    Racine, WI
    Posts
    6
    Sorry, but I'm lost. Will have to look at this tomorrow to figure out how to get this done. Exhausted looking at it.

    Thanks.

  8. #8
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,641
    No problem, post back if you're still stuck. Welcome to the site by the way.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  9. #9
    mejia.j88 is offline Competent Performer
    Windows 7 64bit Access 2007
    Join Date
    Nov 2011
    Location
    california
    Posts
    228
    hi pbaldy

    i have a question along these lines.

    i want a cbo to autopopulate about 7 different boxes. the info is being pulled from a query. do i need to make columns for this cbo box in order to code the auto-population?

    to clarify my question: is the only way to code the population given by
    TxtField1.text= txtCbo.column1 etc.

    i want something along the lines of:

    txtField1.text = Query1.FIELD NAME. something?
    I'm not too sure on how to code this.

  10. #10
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,641
    I would include the columns in the row source. To do it like your example would require DLookup():

    txtField1= Dlookup("FIELD NAME", "Query1", "OptionalCriteria")

    That would be much less efficient. You'd basically be running the query 7 times.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  11. #11
    JudyK is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Feb 2012
    Location
    Racine, WI
    Posts
    6
    Ok, I'm back. Gave up on the macro part. Totally not sure what to do with the VB code. This is what I have:

    Private Sub Street_BeforeUpdate()
    Me.Street = IIf([cboBldgLoc] = "Offsite", [txtHome Street], cboBldgLoc.Column(1))

    End Sub

    My field is called [Street]
    It is populated from Combo Box cboBldgLoc
    If cboBldgLoc has "Offsite" selected in it's box, then I want the field [Street] to use the information entered in field [Home Street]

    Both fields [Street] & [Home Street] are in the same table

    Just very frustrated.

    Thanks for your help. Appreciate your patience.

  12. #12
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,641
    You have that in the before update event of Street. It would typically be in the after update event of cboBldgLoc.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  13. #13
    JudyK is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Feb 2012
    Location
    Racine, WI
    Posts
    6

    Talking

    You are AWESOME! I finally got some quiet time to focus on this and followed what you were trying to tell me. Everything is working perfect thanks to you.

    Thank you for all your help and for being so patient with me.

    Judy

  14. #14
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,641
    No problem Judy, and welcome to the site by the way!
    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: 1
    Last Post: 01-25-2012, 06:46 PM
  2. Update form with table info
    By Hannah's momma in forum Forms
    Replies: 0
    Last Post: 03-23-2011, 12:20 PM
  3. Replies: 9
    Last Post: 02-15-2011, 03:05 PM
  4. Replies: 3
    Last Post: 01-31-2011, 11:47 AM
  5. How to populate info???
    By Access Newbie in forum Access
    Replies: 2
    Last Post: 08-18-2010, 08:51 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