Results 1 to 4 of 4
  1. #1
    Bzbzb1 is offline Novice
    Windows 10 Access 2016
    Join Date
    Jan 2018
    Posts
    2

    Need a hand with something simple


    I'm using a combo box to make some fields visible or invisible and I can't figure out how to specify a column by its header name instead of by using its column number. Here's what I have that works partially:

    Private Sub Sample_Description_AfterUpdate()
    If [Sample Description].Column(1) = "-1" Then
    Me.[125000].Visible = True
    Else
    Me.[125000].Visible = False
    End If
    End Sub

    But since the info in the columns may be changed in the future, since they reference a data sheet that may be altered down the road, I want to specify the column header which is "125000mm" so it would look like this, although this example obviously wouldn't work since I made this up to show what I'm attempting to accomplish.

    Private Sub Sample_Description_AfterUpdate()
    If [Sample Description].ColumnHeader[125000mm] = "-1" Then
    Me.[125000].Visible = True
    Else
    Me.[125000].Visible = False
    End If
    End Sub


    I hope I've been clear.

  2. #2
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,954
    I'm not sure you can do this
    The combobox property .ColumnHeads is a boolean value

    If you think about it, the Column(1) type notation allows for column headers changing in the future.
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  3. #3
    Micron is offline Virtually Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    You might get what you want if you base the combo/form on a query or table that uses captions. The caption should over-ride whatever the field names are, but such a query would have to work with a table whose field names don't change/
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  4. #4
    Gicu's Avatar
    Gicu is offline VIP
    Windows 8 Access 2013
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,101
    I assume you have a table containing the list of fields and their "Show" property. Instead of using a combo box I'd add a loop in the OnLoad or OnCurrent events of the form (depending if the visible property of certain columns vary from record to record) and set the visible property according to your list (I assume you know how to move through a recordset to extract the pair of field name/value from your list)

    dim rst as dao.recordset


    Set rst=currentdb.tabledefs("YourListTable")
    if rst.recordcount=0 then exit sub

    do until rst.EOF
    me.controls(rst("Field")).visible=rst("Show") 'rst("Show") is your field holding the 0 for false and -1 for true
    rst.movenext
    Loop

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

Similar Threads

  1. hyperlink - hand
    By Jen0dorf in forum Access
    Replies: 4
    Last Post: 11-15-2015, 06:23 PM
  2. Calculating Stock On Hand
    By namu23 in forum Access
    Replies: 11
    Last Post: 12-29-2014, 09:08 AM
  3. Still can't get quantiy on hand for all records
    By nightangel73 in forum Queries
    Replies: 6
    Last Post: 06-10-2014, 05:21 AM
  4. Calculate available Assets at hand
    By AIMIS in forum Queries
    Replies: 1
    Last Post: 08-07-2013, 09:06 AM
  5. calculating On Hand Quantity
    By hbm001 in forum Queries
    Replies: 18
    Last Post: 04-24-2012, 09:42 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