Page 1 of 2 12 LastLast
Results 1 to 15 of 24
  1. #1
    mkblack is offline Novice
    Windows 2K Access 97
    Join Date
    Jul 2011
    Posts
    16

    Difficult one: dynamically select field to update

    I have a table with 43 fields and I am building a form to allow users to update the fields in the table. A lot of the fields are memo format, since the data consists of lengthy contract paragraphs.



    I know I can make a huge form with all the fields listed one under the other on the page, and the user would then scroll down and fill each box with data. However, I would prefer to make the user's life easy and allow the user to use a combo box to select wich field they want to work on, and then a box right next to the combo would show the value of the current record for that field.

    (I know that I can set the combo box Field List property with a list of field names in it, but can I link this to a text box so that anything that is written or displayed within it relates to the field displayed in the combo box?)

    Any suggestion would be gretly appreciated!

  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
    I think you can change the control source of the textbox on the fly, so try that in the after update event of the combo. Presuming the combo has the field name in the bound column, try

    Me.TextboxName.ControlSource = Me.ComboName

    You may have to add code to save the record, but see if it works without.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    mkblack is offline Novice
    Windows 2K Access 97
    Join Date
    Jul 2011
    Posts
    16
    Thank you Paul!

  4. #4
    mkblack is offline Novice
    Windows 2K Access 97
    Join Date
    Jul 2011
    Posts
    16
    Paul,

    It doesn't seem to work. When I try to update the combo box, the combo just goes blank, and nothing happens witht he control source of the text box.

    Thanks!

  5. #5
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,640
    Can you post the db here? I just did a very quick test, and it worked as expected.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  6. #6
    mkblack is offline Novice
    Windows 2K Access 97
    Join Date
    Jul 2011
    Posts
    16
    Unfortunately, the Db contains confidential info, otherwise I would be happy to post it. This is the code that I have:

    Private Sub Combo0_AfterUpdate()
    Me.Text2.ControlSource = Me.Combo0
    End Sub

  7. #7
    mkblack is offline Novice
    Windows 2K Access 97
    Join Date
    Jul 2011
    Posts
    16
    I get #Name in the text box

  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,640
    I tested with this and it worked fine:

    Code:
    Private Sub Combo6_AfterUpdate()
      Me.Text0.ControlSource = Me.Combo6
    End Sub
    Make sure your combo's bound column contains valid field names. The #Name error is what you'd get if Access didn't recognize the field name.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  9. #9
    mkblack is offline Novice
    Windows 2K Access 97
    Join Date
    Jul 2011
    Posts
    16
    Paul,

    Thank you for taking the time to help! Let me give you some detial on the form and underlying table. I will act like the table onyl has five columns:

    table name: Documents_P
    Fields:
    DOCUMENT_ID
    Document_Date
    Address_Change_Terms
    Insurance_Requirement_Terms
    Address_Change_Date

    Let's assume that on the form I will be on a current record having DOCUMENT_ID=10. For that document I want to be able to enter into either of the fields. In the combo I want to select which field I want to edit (or to enter a new value for tha field) and then I want the text box to show me the value currently in the field, which I could then edit.

    Is this indicative enough of what I am trying to accomplish?

  10. #10
    mkblack is offline Novice
    Windows 2K Access 97
    Join Date
    Jul 2011
    Posts
    16
    got it!!! thank you! I just had to add
    Me.Text2.ControlSource = Me.Combo0.Column(1)

  11. #11
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,640
    Excellent, glad we got it sorted out!
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  12. #12
    mkblack is offline Novice
    Windows 2K Access 97
    Join Date
    Jul 2011
    Posts
    16
    Yes. Sorry to bug again, but one issue remains: The update works well, but the combo is still blank after the update. I am trying to put in another text box that would show the name of the field being updated, and I set its control source to =[Combo0], but naturally that text box is blank, as well.

  13. #13
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,640
    What are the row source, bound column and column width properties of the combo?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  14. #14
    mkblack is offline Novice
    Windows 2K Access 97
    Join Date
    Jul 2011
    Posts
    16
    Row Source: Documents_P
    Bound Column: 1
    Column Width: 1

  15. #15
    mkblack is offline Novice
    Windows 2K Access 97
    Join Date
    Jul 2011
    Posts
    16
    This is a screen shot of the basic form layout.

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 7
    Last Post: 11-24-2014, 02:11 PM
  2. Select Query > Update Query > Table Field
    By tuggleport in forum Queries
    Replies: 2
    Last Post: 08-09-2012, 07:04 AM
  3. Update query using iif and select
    By josh2009 in forum Queries
    Replies: 1
    Last Post: 04-23-2010, 11:33 PM
  4. Replies: 1
    Last Post: 06-01-2009, 04:05 PM
  5. very difficult (for me!) SELECT query
    By igorbaldacci in forum Queries
    Replies: 1
    Last Post: 12-02-2008, 03:30 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