Page 3 of 3 FirstFirst 123
Results 31 to 41 of 41
  1. #31
    blakebaker008 is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    May 2017
    Posts
    3

    I was also facing the personal ID security problem, I was not interested in submitting my personal ID there. Now its all clear with your valuable ideas guys, thank you so much for your discussion.

  2. #32
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Did you advance the code to the next line? In your sample, the variable is getting a value.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #33
    Lou_Reed is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2015
    Posts
    1,664
    As I said the columns on the combo box query for the db are PersonnelID, Full_Name, and email_address. The strWho should obviously be connected with Full_Name. The strEmailaddress should be connected to emailaddress, I have not created a string emailaddress in the VBA code yet, but I will since I know I need it to connect . That is how I wish to do it. I obviously am not doing that now.

    The line of code where the program chokes is: strWho = Me.cboEmployeeName.Column(1). It is reading the first or second column, I have forgotten. If strWho = Me.cboEmployeeName.Column(1) is correct then,
    the next line would be: Stremailaddress = Me.cboEmployeeName.Column(2) or the next column over from fullname. This clearly dependent on whether the first line is correct.

    This is my approach. I hope that you think it is correct.

    Respectfully,

    Lou Reed

  4. #34
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    In your sample, these lines of code:

    Code:
    strWho = Me.cboEmployeeName.Column(1)
    Debug.Print strWho
    Debug.Print Me.cboEmployeeName.Column(2)
    produce this result:

    Bela Lugosi
    Bela_Lugosi@yahoo.com
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #35
    Lou_Reed is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2015
    Posts
    1,664
    No it does not. It causes the code to go to a error region at the bottom of code lines for frmEmail as shown below:

    Code:
         Err_cmdSend_Email_Click:
         MsgBox Err.Description
         Resume Exit_cmdSend_Email_Click
    So obviously it is not getting info from the columns produced by the SQL code in cboEmployeeName.

    Respectfully,


    Lou Reed

  6. #36
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Getting the columns most certainly works in the copy you posted. What does not work is the DLookup(), as mentioned because you're comparing the ID to the name.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  7. #37
    Lou_Reed is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2015
    Posts
    1,664
    How do you know that PersonnelID has a numeric data type? Do you go all the way back to the table where it was defined? It makes sense that PersonnelID has numeric data type, but just how do you know?

    I believe I am asking this to determine the connection type from the MS Access code to the VBA code. that seems to be the type of contention. If that is wrong then you get mismatch error.

    Any help appreciated. Thanks in advance.

    Respectfully,

    Lou Reed
    Last edited by Lou_Reed; 06-12-2017 at 07:27 AM. Reason: correction

  8. #38
    Lou_Reed is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2015
    Posts
    1,664
    In the VBA code for frmEmail there is a line:

    strWho = Me.cbo.EmployeName.Column(1)

    The form is looking for a numeric value and the VBA code is looking for text value. Hence when the code is run I get a mismatch error.

    The next line of interest is :

    varTO = DLookup("[email address]". tblPersonnel", StWhere)

    which is wrong. It is quite messy. An easier way to get varTO is:

    VatTO = Me.cbo.EmployeName.Column(2)

    Now the code is trying to get text which is an email address for the strWho selected in the previously discussed line.

    That should do it for getting varTO and strWho.

    The row source code for the EmployeeName combo box is:

    Code:
    SELECT tblPersonnel.PersonnelID, [FirstName] & " " & [LastName] AS FullName, tblPersonnel.emailaddress
    FROM tblPersonnel
    ORDER BY [FirstName] & " " & [LastName];

    The output when I run the SQL code is shown in the attached file.


    Repeat :

    It assumes that VBA code the first column is 0 , the second column is 1 and the third column is 2.

    Also, it assume that is MS Access 2010 the first column is 1, the second column is 2 and the third column is 3.


    Is not this the way to correct the error?

    Any help appreciated. Thanks in advance.

    Respectfully,

    Lou Reed
    Attached Files Attached Files

  9. #39
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Yes, I looked in the table at the data type. I'm not sure what you're asking now. The mismatch error occurs because you're comparing name (text) to ID (numeric). Either compare the ID field to Column(0) or the name field (less accurate) to Column(1). Or dump the DLookup() and use Column(2) for the email.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  10. #40
    Lou_Reed is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2015
    Posts
    1,664
    Code:
    Either compare the ID field to Column(0) or the name field (less accurate) to Column(1).  Or dump the DLookup() and use Column(2) for the email.
    If you look my post right before this post that is exactly what I did. I am just concerned about the interface between VBA and MS Access. In MS Access I can go back to the table and look at the field and determine if it is numeric or text. In the VBA code however, variable that I am trying to set equal to the value of the MS Access table field, must of course match.

    I am just not sure how to accomplish that. I assume that when you define a variable such as strWho as string then that is the correct way to it will match up with Me

    Fullname column is clearly text, so StrWho must match that column or as you say column(1) must be string. The email address is clearly text so to set varTO equal to what is in column(2) must be text. The PersonnelID column is just there, it is of no use to me except in creating the combo box. It is clearly a numeric field so Me.cbo.EmployeName.Column is clearly numeric or a number field.

    The VBA code has a variable definition section, but I am not sure if that is where to set the values, strWho and varTO to string. I assume it is since there is no other place for it variable definition.

    If I am correct here please tell me.

    Respectfully,

    Lou Reed

  11. #41
    Lou_Reed is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2015
    Posts
    1,664
    The db works now with the corrections that you suggested. I am just confused again by the use of VBA variables. Some are strings and some are variants, there are more variable defsbut that seems enough to get the db to work. Just what is the difference between a string and a variant VBA variable type. If a numeric field in a table is set to a VBA variable, what type variable is it set to? If a text value field is set to a VBA variable what type of variable is it set to?

    Any help appreciated. Thanks in advance.

    Respectfully,

    Lou Reed

Page 3 of 3 FirstFirst 123
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 4
    Last Post: 03-11-2017, 09:48 PM
  2. Access2010 - email automation (if not NULL)
    By MikeDub in forum Access
    Replies: 3
    Last Post: 12-18-2014, 07:34 PM
  3. Replies: 5
    Last Post: 05-07-2014, 09:25 AM
  4. Program Link to Outlook Email from a Buttom
    By taimysho0 in forum Programming
    Replies: 7
    Last Post: 11-23-2011, 02:07 PM
  5. Program a 30-day trial into my Access Program?
    By genghiscomm in forum Programming
    Replies: 1
    Last Post: 05-26-2011, 02:14 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