Results 1 to 4 of 4
  1. #1
    Lou_Reed is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2015
    Posts
    1,664

    The statemewnt give the same result

    In the small db file that I have attached it seems that in the form that opens frmHelpDeskTickets the VBA code behind the - send ticket - command is rather vague. This code works completely, but it is hard to understand the difference between the use of stWho and stWhere.

    They produce the same thing, the the same value, so what is the difference?



    Any help appreciated. Thanks in advance.

    Respectfully,


    Lou Reed

    Okay, I looked at it again and it does seems that stWho and stWhere have one slight difference. The stWhere does indicate a the tblUsers, which is where the name comes from. I just do not see how that can make a difference. Please explain.
    Attached Files Attached Files
    Last edited by Lou_Reed; 04-05-2017 at 02:32 PM. Reason: addition

  2. #2
    jwhite is offline Competent Performer
    Windows 10 Access 2013 32bit
    Join Date
    Dec 2012
    Location
    North Carolina
    Posts
    349
    I see that this is an example database from DatabaseDev.

    1. stWho is assigned the value of the "Assigned To" selected (Me.cboAssignee)
    2. stWhere is assigned with the table field to compare to and the value of stWho
    3. varTo is assigned the value of the DLookUp() function based on the value of stWhere.

    All of that could have been accomplished in one simple line and adding Nz in case it wasn't found:

    varTo = Nz(DLookup("[strEMail]","tblUsers","strUserID = '" & Me.cboAssignee & "'"),"")

    Did you change the table fields to have "str" at the beginning? The prefix is meant for code variables, not field names.

  3. #3
    Lou_Reed is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2015
    Posts
    1,664
    No not yet, I have not changed the variables from st to str. I guess, I will just leave them as they are for now. I probably will follow that protocol
    in the future.

    It just seems that stWho and stWhere do give you the same value on the right had side. I believe it is jones_J. However, There is a table attached (tblUsers) with stWhere. I thought these
    values were to only be one. Not a combination of more than one as in the case of stWhere? It just seems confusing.

    Respectfully,

    Lou Reed

  4. #4
    andy49's Avatar
    andy49 is offline VIP
    Windows 10 Access 2007
    Join Date
    Nov 2016
    Location
    London
    Posts
    1,051
    Hope this helps Lou. My comments are in red



    Code:
    stWho = Me.cboAssignee 'sets stWho as the ID of the person who is Assignee
        stWhere = "tblUsers.strUserID = " & "'" & stWho & "'" 'creates a criteria for the where part of the Dlookup and calls is stWhere 
        '-- Looks up email address from TblUsers
        varTo = DLookup("[strEMail]", "tblUsers", stWhere) 'Looks up the email address of the person who's UserID is Stwho. It looks in the stremail column of the tblusers table using the criteria stwhere

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

Similar Threads

  1. Give number to record
    By Michiel Soede in forum Access
    Replies: 3
    Last Post: 07-10-2016, 05:47 AM
  2. Give values to List Box using vba
    By gstylianou in forum Access
    Replies: 11
    Last Post: 01-14-2016, 02:11 PM
  3. hello Everyone who can give help on this ?
    By YaseenIskaf in forum General Chat
    Replies: 1
    Last Post: 05-23-2013, 01:57 PM
  4. DB will not give Unique ID's
    By DICKBUTTONS in forum Access
    Replies: 1
    Last Post: 02-07-2012, 02:12 PM
  5. Should I give Up on This Form?
    By Palomino33 in forum Forms
    Replies: 25
    Last Post: 11-09-2011, 05:37 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