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

    Getting values frrom a combo box

    I thought that I put this question up yesterday. I guess I did not. I am trying to debug the following section of code in frmEmail.

    Code:
     '-- Combo of name to send email to
        StWho = Me.cboFullname
        stWhere = "tblusers"
        '--Looks up email address from Personnel Meeting Query
        varTO = DLookup("stEmail", "", stWhere)
    It is giving me at the first executable line that StWho = Peter Cushing@yahoo.com (a made up name and email address) now it is reading the wrong column in the
    combo box. StWho should just be Peter Cushing only, without the email address. I was not sure yesterday why this was happening, but I think that I know now.

    It is reading the wrong column here. For some reason it is reading the email address column and not the Fullname column. It is hard to explain since I thought I labeled it quite clearly.

    The solution I believe is to make it read the correct column.

    change the line:

    StWho =Me.cboFullname

    to

    StWho =Me.cboFullname(1)



    In the first case it is reading the first column and in the second it is reading the second column.

    This seems to be the answer.

    My question is doesn't

    Me.cboFullname

    mean anything. The cboFullname part should direct the user to read that column and not email address. It is just place holder it seems.

    I have attached a file and the *.png screenshot of what I am speaking about.

    Any help appreciated. Thanks in advance.



    Respectfully,

    Lou Reed
    Attached Thumbnails Attached Thumbnails 2017-04-03_16-05-03.png  
    Attached Files Attached Files

  2. #2
    andy49's Avatar
    andy49 is offline VIP
    Windows 10 Access 2007
    Join Date
    Nov 2016
    Location
    London
    Posts
    1,051

    Getting values frrom a combo box

    The dlookup line is wrong Lou. It should be something more similar to

    dlookup("nameof emailcolumn??", strwhere, "fullnamefield=" stwho)


    Dlookup format is dlookup(field,table,criteria)

    Sent from my iPhone using Tapatalk

  3. #3
    Lou_Reed is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2015
    Posts
    1,664
    Okay, but I am talking about the line a few lines above. I am setting a value stWho to a value in the combo box. It is reading the wrong column. I can change that. But does the Fullname name mean anything? Is it a placeholder?

    R,


    Lou Reed

  4. #4
    andy49's Avatar
    andy49 is offline VIP
    Windows 10 Access 2007
    Join Date
    Nov 2016
    Location
    London
    Posts
    1,051

    Getting values frrom a combo box

    Me.cbofullname is the name of a combobox on that form.
    All that line does is save the combobox value to the variable stringwho. But the combobox only has the column set in the bound property.

    I suspect this code runs when you change that combobox.

    To get a closer look at the values in the combobox, have a look at its row source (properties) and then look for its bound column (properties but remember the first column is column 0)

    If it helps use something like msgbox stringwho after the highlighted line.

    Change me.cbofullname.column(1) to whatever you want until you see the column you need in a msgbox


    Sent from my iPhone using Tapatalk

  5. #5
    Lou_Reed is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2015
    Posts
    1,664
    Thank you I will give it a try.

    R,

    Lou Reed

  6. #6
    Lou_Reed is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2015
    Posts
    1,664
    I used several columns when I made up that combo box. One was email address(which includes the name) and the other was fullname. For some reason it is setting StWho to email address. I am guessing then that must be the bound column or column 1. So how do I make I select the name column the one I want? Do I change the bound column from column 1 or do I use a line like:

    StWho = cbofullname(1)

    to make it move from the first column to the second column, column 1. I really have forgot which column is what since I wrote the combobox line. I just know that there are at least two fields one email and one fullname. This is what is so confusing about combo boxes. If I could just see what the columns are then this would be an easy fix. But I cannot.


    Respectfully,

    Lou Reed

  7. #7
    andy49's Avatar
    andy49 is offline VIP
    Windows 10 Access 2007
    Join Date
    Nov 2016
    Location
    London
    Posts
    1,051
    Can you find the row source for the combobox and paste it in here?


    Sent from my iPhone using Tapatalk

  8. #8
    andy49's Avatar
    andy49 is offline VIP
    Windows 10 Access 2007
    Join Date
    Nov 2016
    Location
    London
    Posts
    1,051
    On a secondary note, if this is the only thing your getting from the combobox then change the bound column.

    Using combo.column("email") or combo.column(2) may be less likely to cause issues.


    Sent from my iPhone using Tapatalk

  9. #9
    Lou_Reed is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2015
    Posts
    1,664
    I am assuming that the bound column is the email address column, which I suppressed in the display for the initial combo box by making its width equal to 0.

    That must also mean that column numbers start at one not zero. The bound column, column 1 is the email column, it is the first column and it has a width of zero. Do not forget the combo box initially shows a name value when used. It is the second column.

    So the name column must be column 2. So how do I get the cbofullname to select the name column and not the email address column.

    StWho = cbofullname

    I got it working in the form, frmEmail.

    The solution must not include changing the bound column, other things are dependent on that. It must be left alone.

    So it must be in the statement that I show above. It cannot be anything else. But how do I change the statement?

    Any help appreciated. Thanks in advance.

    Respectfully,

    Lou Reed
    Last edited by Lou_Reed; 04-04-2017 at 10:39 AM. Reason: correction

  10. #10
    andy49's Avatar
    andy49 is offline VIP
    Windows 10 Access 2007
    Join Date
    Nov 2016
    Location
    London
    Posts
    1,051
    Strwho= cbofullname.column(2)

    Put
    msgbox strwho
    After that line and a message box will pop up saying hopefully the name.


    Sent from my iPhone using Tapatalk

  11. #11
    Lou_Reed is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2015
    Posts
    1,664
    I thought so, thanks for your input.

    R,

    Lou Reed

  12. #12
    andy49's Avatar
    andy49 is offline VIP
    Windows 10 Access 2007
    Join Date
    Nov 2016
    Location
    London
    Posts
    1,051
    Anytime


    Sent from my iPhone using Tapatalk

  13. #13
    Lou_Reed is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2015
    Posts
    1,664
    Strwho= cbofullname.column(2)

    did not work.

    The only thing that I can think of is a syntax error. No matter what I put in there it threw an error.

    As I said I am guessing syntax. By leaving it out the line does not throw an error. Any other value 0,1,2 results in StWho = "" and is an error.

    I am including the db in case someone wants to try it. oOpen db and pen frmEmail and press send email. Then you will see.

    I cannot think of anything else.

    Any help appreciated. Thanks n advance.

    Respectfully,

    Lou Reed
    Attached Files Attached Files

  14. #14
    andy49's Avatar
    andy49 is offline VIP
    Windows 10 Access 2007
    Join Date
    Nov 2016
    Location
    London
    Posts
    1,051

    Getting values frrom a combo box

    Lou I can't get into the file as don't have a pc. What is the recordset in the properties of the cbofullname.

    Did you use me.cbofullname.column(2)???

    Sent from my iPhone using Tapatalk

  15. #15
    Lou_Reed is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2015
    Posts
    1,664
    I am not understanding what this is about. I am sure it does not include recordsets, however.

    I will try using a designing a new combo box, that is all that I can think of. If anyone knows the answer
    please post.

    Respectfully,

    Lou Reed

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

Similar Threads

  1. Replies: 7
    Last Post: 03-07-2017, 03:01 PM
  2. Replies: 11
    Last Post: 09-03-2015, 11:12 AM
  3. Replies: 3
    Last Post: 07-03-2013, 10:38 AM
  4. Replies: 1
    Last Post: 10-03-2012, 04:12 PM
  5. Replies: 1
    Last Post: 03-27-2010, 06:13 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