Page 1 of 2 12 LastLast
Results 1 to 15 of 17
  1. #1
    Lou_Reed is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2015
    Posts
    1,664

    What does this part of the statement mean?

    In the attached file which a MS Access db file, I am unsure what the line:

    strHelpDesk = Me.cboReceivedBy.Column(1)


    I understand that strHelpDesk is being set to something. form the cboRecivedBy on the current form. Just what does the

    Column(1)

    mean I

    Me.cboReceivedBy.Column(1).

    It seems unnecessary, could not the executable statement stand with out it?

    Any help appreciated. Thanks in advance.


    Respectfully,




    Lou Reed
    Attached Files Attached Files

  2. #2
    Bulzie is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    Nov 2015
    Posts
    1,463
    Your combo box has 2 fields, to reference the 2nd field you do that by using the .column() code. So your field cboReceivedBy might have these fields(ReceivedByDate, ReceivedByName, ReceivedByTime) To reference the first field, it is just Me.cboReceivedBy, to reference the 2nd field it is Me.cboReceivedBy.Column(1), and the third field would be Me.cboReceivedBy.Column(2). If you only see 1 field when you pull down the list, the other field(s) have width of 0 so are in effect hidden by the pull down list but are still there.

  3. #3
    Lou_Reed is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2015
    Posts
    1,664
    Okay, thanks I thought it had to be something like that. I had just never seen this format before. That was the purpose of the posting.


    Respectfully,

    Lou Reed

  4. #4
    Lou_Reed is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2015
    Posts
    1,664
    Another question the first filed is designated 0 and the second 1, third 3 and so on?

    When I write the statement :

    Me.cboReceivedBy.Column(1)

    as

    Me.cboReceivedBy.

    There seems to be no change. Yet, I am now referencing the first not the second column.

    Respectfully,

    Lou Reed

  5. #5
    Bulzie is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    Nov 2015
    Posts
    1,463
    Yeah i think so, just test it to get the correct reference number.

  6. #6
    Lou_Reed is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2015
    Posts
    1,664
    I am attaching two screenshots. The first is with the full statement

    Me.cboReceivedBy.Column(1)

    and the second is without the Column(1) statement. It seems that they are the same.

    The one with the lowest number (11-04.png) is with column(1) and the one with the highest (14-07.png) number is without it.

    I am not sure which is correct. There simply is no difference that I can see.


    Respectfully,


    Lou Reed
    Attached Thumbnails Attached Thumbnails 2017-03-27_16-14-07.png   2017-03-27_16-11-04.png  

  7. #7
    jwhite is offline Competent Performer
    Windows 10 Access 2013 32bit
    Join Date
    Dec 2012
    Location
    North Carolina
    Posts
    349
    In forms design, the index is 1-based - starts with 1
    In VB code, the index is 0-based - starts with 0.
    Me.txtControl returns the 0-based element
    Me.txtControl.Column(0) returns the first 'column' according to your rowsource
    Me.txtControl.Column(1) returns the second 'column' according to your rowsource

    There is no way Me.txtControl and Me.txtControl.Column(1) would be the same unless the data is the same in both columns.

  8. #8
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,398
    There is no way Me.txtControl and Me.txtControl.Column(1) would be the same unless the data is the same in both columns
    unless txtControl is bound to column 2 (as mentioned by jwhite, bound column enumerations start from 1, column collections enumerate from 0)

  9. #9
    Micron is offline Virtually Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    bound column enumerations start from 1
    99.9% true for the most part since that would be the way most would design it.
    You can specify zero (0) in form design and it will become the zero based index number of the list. In that case, it will write the list index value to the table field that the control is bound to. Not that I've ever used it that way, nor do I know how to replicate that in vba.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  10. #10
    Lou_Reed is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2015
    Posts
    1,664
    I am not sure that I understand those last few posts. I put this on my MS Access 2016 and ran the two mdb files. The original had Me.cboReceivedBy.Column(1) and the copy had
    Column(1) part missing.It seems that there is no difference. Again I have to ask why Column(1) is required?

    Respectfully,

    Lou Reed

  11. #11
    John_G is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2011
    Location
    Ottawa, ON (area)
    Posts
    2,615
    You are using the column reference in strHelpDesk = Me.cboReceivedBy.Column(1). But strHelpDesk is just a string variable in your code - your form does not display it, so you won't see any difference between using column(1) or not.

    Where the difference would show up is in the E-Mail contents. Leaving out the Column(1) will put just the Employee ID in the E-mail - you need Column(1) (i.e. the second column on the combo box) the get the Employee Name.

  12. #12
    Lou_Reed is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2015
    Posts
    1,664
    Thanks I will check it out.

    Respectfully,

    Lou Reed

  13. #13
    Lou_Reed is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2015
    Posts
    1,664
    Thanks it looks like you are correct. This is much appreciated.

    Respectfully,

    Lou Reed

  14. #14
    Lou_Reed is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2015
    Posts
    1,664
    Code:
    Where the difference would show up is in the E-Mail contents.  Leaving out the Column(1) will put just the Employee ID in the E-mail - you need Column(1) (i.e. the second column on the combo box) the get the Employee Name.

    There are other ways to do this. Are they not? Say I leave

    Me.cboReceivedBy.Column(1)

    in but write it as

    Me.cboReceivedBy


    Then make the first column in the combo box invisible or make it have 0 width.

    Would that achieve the same end?

    Any help appreciated. Thanks in advance.

    Respectfully,

    Lou Reed

  15. #15
    John_G is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2011
    Location
    Ottawa, ON (area)
    Posts
    2,615
    Would that achieve the same end?
    No. The column widths are for display only - it doesn't make the column disappear. Combo boxes are often set up this way, with the first column hidden and containing a numeric ID (often a table PK), and the second column (the one that is visible in the combo) displaying user-friendly text. You still need the .Column(1) to refer to the second column.

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

Similar Threads

  1. Replies: 3
    Last Post: 02-18-2016, 07:26 PM
  2. if statement for part of string
    By fishhead in forum Macros
    Replies: 4
    Last Post: 04-23-2015, 02:50 PM
  3. Part of field matches part of another field
    By fishhead in forum Queries
    Replies: 13
    Last Post: 04-10-2015, 01:54 PM
  4. How Can export Large table part by part
    By shabar in forum Import/Export Data
    Replies: 2
    Last Post: 02-04-2013, 06:29 AM
  5. If Statement Doesn't Do Else Part
    By hammer187 in forum Programming
    Replies: 20
    Last Post: 10-03-2012, 03:44 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