Want column 2 not bound column

chappy68

Registered User.
Local time
Yesterday, 18:58
Joined
Aug 15, 2011
Messages
76
This seems to be a common question but I can't get it to work with any of the suggestions I have seen. Here is my problem.

My row source is a query bound to the ID in column 1. I want the Client Name in column 2. In the red highlighted portion of the code, if I leave the .column(2) off, my result is the ID number of the client. Once I add the eval() and .column(2), I get an error "invalid use of null".

What have I done wrong? I left out the rest of the code since this is where my problem lies.

Code:
Private Sub butSendEMail_Click()
    On Error GoTo butSendEMail_Click_Err
    Dim varTo As Variant           '-- Address for SendObject
    Dim stSubject As String        '-- Subject line of e-mail
    Dim stUserName As String    '-- Person who assigned ticket
    Dim stCName As String        '-- Name of client
    Dim stCNum As String         '-- Client number
    Dim stText As String           '-- E-mail text
 
    '-- Email address to send email to
    varTo = [EMAIL="test@test.com"]test@test.com[/EMAIL]
 
    '-- Subject line of email
    stSubject = ":: Bookkeeping task completed ::"
 
    '-- Employee who is sending message
    stUserName = Forms!frmLogin!txtLoginFN
 
    '-- Determine client name
[COLOR=red]   stCName = Eval(Forms!frmMyTasks!sfrmMyTasks.Form.ClientName.Column(2))[/COLOR]
 
Are you aware that the columns in Combo Boxes and List Boxes for that matter are Zero indexed? That is to say that the first column is Column(0) and the second column is Column(1) etc.
 
Are you aware that the columns in Combo Boxes and List Boxes for that matter are Zero indexed? That is to say that the first column is Column(0) and the second column is Column(1) etc.


I am now. The query only has 2 columns so that is why it would be null. I tried it and it worked.

Thanks for the help. Hate it when I miss the small stuff. I can't tell you how many times I have read that and I still forgot it.
 
it's awkward in access/vba. some things are zero based, and others one based.

it's just trial and experience (and a good memory)
 

Users who are viewing this thread

Back
Top Bottom