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

    A case of mere substitution

    In the *.png attachment that I have attached to this post shows some source
    code from a program that I know runs and does what it is expected to do.

    The main issue is the code line shown below:




    (1) stWhere = "tblUsers.strUserID = " & " ' " & stWho & " ' "


    This statement works and does what it is expected to do.

    Now in my program the record source is not tblUsers, but it is a query


    (2) qry Personnel Meeting Query.email address


    Now I know that this statement has far too many spaces in the record source name, but that is another
    post not this one.

    I am assuming that the like the record source in the first (running program) the record source which is a query
    can be dropped right in to replace tblUers with qry Personnel Meeting Query. Also the field that I want to attach to it
    strUersID in the working program's case and email address in mine, that it is just a simple matter of substituting strUersID with
    email address.

    Then the statement should work.

    Now I can also say that in each case, the variant stWho is properly defined.

    However, the statement that I created does not work.

    I get after using it stWhere = false, which I assume is an error.

    I have attached a *.png file, which, dislays the code in question from the working program.

    Is there an erro in my logic.

    Any help appreciated. Thanks in advance.

    Respectfully,

    Lou Reed


    PS I cannot explain the underlining of my written post it just seems to have occurred randomly.



    Attached Thumbnails Attached Thumbnails 2017-04-05_9-54-19.png  

  2. #2
    Bulzie is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    Nov 2015
    Posts
    1,511
    stWhere = "tblUsers.strUserID = '" & stWho & "'"

    singlequote doublequote & stWho & doublequote singlequote doublequote

  3. #3
    jwhite is offline Competent Performer
    Windows 10 Access 2013 32bit
    Join Date
    Dec 2012
    Location
    North Carolina
    Posts
    349
    Lou, you didn't post the errant code...

    From your previous database upload, you had these lines in cmdSend_Email_Click():

    '-- Combo of name to send email to
    StWho = Me.cboFullname.Column(1)
    stWhere = "qry Personnel Meeting Query.email address" = " & " '" & stWho & "'"
    '--Looks up email address from Personnel Meeting Query
    varTO = DLookup("email address", "qry Personnel Meeting Query", stWhere)

    The stored query does not have a space between qry and P, and the spaces in the objects names need bracketed:

    '-- Combo of name to send email to
    StWho = Me.cboFullname.Column(1)
    stWhere = "[qryPersonnel Meeting Query].[email address] = '" & stWho & "'"
    '--Looks up email address from Personnel Meeting Query
    varTO = DLookup("[email address]", "qryPersonnel Meeting Query", stWhere)

    Before going forward I would urge you to correct all objects to not have spaces in them - coding will be much easier without them.

  4. #4
    Lou_Reed is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2015
    Posts
    1,664
    That is what I am doing. In fact I am doing it for the whole db. I am doing my best to take out the space in between words in names, etc.

    What I would like to know is there a way to get the summary of the complete db control, object, record source, control source, table name etc. I believe that there is and it lists all variables
    in some order and shows where they are used. It is organized just going through each table and VBA code, I may find them all, but this tool lists everything.

    I know that after you complete summary of the db can done, so I am hoping that I can do something like this at this point, to see if I have any outliers (so to speak) in terms of names that
    were not changed and are not screwing up db operation.

    This method makes a huge document (over a hundred pages), but that is okay. I have an electronic reader.

    Any help appreciated. Thanks in advance.

    Respectfully,


    Lou Reed

  5. #5
    jwhite is offline Competent Performer
    Windows 10 Access 2013 32bit
    Join Date
    Dec 2012
    Location
    North Carolina
    Posts
    349
    What tool did you use? Personally I would walk through all objects manually - surely this isn't a huge application yet? It would be hard for a utility to give a summary of objects with spaces and/or variable names without proper prefix. Just saw this and may be helpful in other respects: https://xldennis.wordpress.com/2010/...vba-inspector/

  6. #6
    Lou_Reed is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2015
    Posts
    1,664
    The tool that I used was just my hands and head. I am sure that I missed couple of them (or more) and any useful software tool that could help would be welcome.

    I tried Richard Fisher's Find an Replace, it works awkwardly with Win 10 Pro. I abandoned it.

    I will try you reference. I just cannot get to it now.

    Any help appreciated. Thanks in advance.

    Respectfully,

    Lou Reed

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

Similar Threads

  1. Table name substitution in DLookup
    By GraeagleBill in forum Programming
    Replies: 3
    Last Post: 12-16-2016, 08:08 PM
  2. String Variable substitution for SetFocus
    By GraeagleBill in forum Programming
    Replies: 1
    Last Post: 08-23-2014, 07:08 PM
  3. Replies: 5
    Last Post: 10-23-2012, 03:55 PM
  4. Replies: 3
    Last Post: 10-20-2012, 11:52 AM
  5. Variable substitution problem.
    By bsc in forum Programming
    Replies: 2
    Last Post: 01-11-2012, 09:33 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