Results 1 to 6 of 6
  1. #1
    DMJ's Avatar
    DMJ is offline Advanced Beginner
    Windows Vista Access 2007
    Join Date
    Oct 2011
    Posts
    32

    Text Box Expression not working from a ComboBox

    I have a 4 column comboBox set up which is working fine. It only displays info from one column of course, so I set up a textbox to display another column but I keep getting back #Name?. I have put in the expression =[Person_LastName_ComboBox].[Column](2)
    What am I missing? I am using Access 2007.

  2. #2
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    I assume that this expression is in the Control Source of the Textbox. In an expression in a Control Source, Square Brackets denote a Control on the Form, so with this

    =[Person_LastName_ComboBox].[Column](2)

    you're telling the Access Gnomes that Column is a Control on your Form, which it isn't, of course, and you're probably confusing the poor lads no end! You should be able to use

    =[Person_LastName_ComboBox].Column(2)

    without any problem.

    Control Sources can be quirky, at times, when Expressions are used. Running 2007, like yourself, I actually set up a quick db to replicate yours, and used your

    =[Person_LastName_ComboBox].[Column](2)

    and it popped an error citing 'incorrect syntax' in the Expression. I closed the file, re-opened it, and tried again, and it worked! When I went into Form Design View and looked at the Control Source for the Textbox, the Gnomes had removed the Square Brackets around Column! As I said, quirky!

    I usually do this sort of thing using the AfterUpdate event of the Combobox, something like this:

    Code:
    Private Sub Person_LastName_ComboBox_AfterUpdate()
     Me.TargetTextbox = Me.Person_LastName_ComboBox.Column(2)
    End Sub

    You'd just have to replace TargetTextbox with the actual name of the Textbox that you want to use to display the Value.

    Linq ;0)>

  3. #3
    DMJ's Avatar
    DMJ is offline Advanced Beginner
    Windows Vista Access 2007
    Join Date
    Oct 2011
    Posts
    32

    attached zipped file

    frm-PersonAddressPhoneEDIT


    Attachment 11586

  4. #4
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    The Control Source for your Textbox is

    =[Person_LastName_ComboBox].[Column](2)

    The problem with that is that

    Person_LastName_ComboBox

    is the Caption of the Label for your Combobox! The actual Combobox is named

    Combo55

    so you need to change the Control Source of the Textbox to

    =[Combo55].[Column](2)

    However, if you wanted both First and Last Name to appear in the Combobox, after a selection is made, you could widen the Combobox and change the Row Source of the Combobox to

    Code:
    SELECT [tbl_Person].[PersonID], [tbl_Person].[Person_FirstName] & "  " & [tbl_Person].[Person_LastName], [tbl_Person].[Inmate_CS#] FROM tbl_Person ORDER BY [Person_FirstName];

    Linq ;0)>

  5. #5
    DMJ's Avatar
    DMJ is offline Advanced Beginner
    Windows Vista Access 2007
    Join Date
    Oct 2011
    Posts
    32
    Thank you very much! You made my day!

  6. #6
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    Glad we could help!

    Linq ;0)>

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

Similar Threads

  1. Expression for a text box
    By venu_resoju in forum Reports
    Replies: 4
    Last Post: 01-24-2013, 10:27 PM
  2. Expression not working in query
    By Bob Blooms in forum Access
    Replies: 4
    Last Post: 08-25-2012, 08:42 AM
  3. Replies: 2
    Last Post: 10-02-2011, 01:27 PM
  4. vba code not working with combobox
    By bopsgtir in forum Programming
    Replies: 9
    Last Post: 02-24-2011, 11:27 AM
  5. combobox.dropdown event not working after error
    By perlyman in forum Programming
    Replies: 1
    Last Post: 04-02-2010, 06:55 PM

Tags for this Thread

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