Results 1 to 9 of 9
  1. #1
    lawdy is offline Competent Performer
    Windows 7 32bit Access 2013
    Join Date
    Jan 2013
    Posts
    172

    Wildcard Charcters

    I posted something similar to this earlier but I got lost. I am trying it again. Many of the properties (buildings) that we do proposals for have a site plan. They are stored in a folder (or directory) just for them. There would be only one file for any given property. However, there could be a choice of one of many file types (extensions) as pdf, jpg, xls, and many more. I am trying to search for the file using the wildcard character '*'. Below is my code which does not return anything. The line in red is the line which should select the file. The variables 'strSitePlanLoc' and 'strPropertyName' produces the correct path and property name, but no file is attached. I can change the & ".*" to & ".pdf" and (provided there is a pdf file of that property) then the file is attached. Help is appreciated.






    With rst
    Do Until rst.EOF
    strPropertyName = ![fTxtJobName]
    lngProposalNo = ![fLngProposalNo]



    ' make sure a property is listed
    If strPropertyName > "" Then ' contains a value
    ' then find the file
    strFullFileName = strSitePlanLoc & strPropertyName & ".*"
    ' determine if a site plan exist
    strFileName = dir(strFullFileName) ' returns only file name
    If strFileName > "" Then ' it will be 0 is no file exist
    ' then attach the file to the email
    olMailItem.Attachments.Add strFullFileName
    End If
    End If

  2. #2
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,776
    I'm baffled as to why you would start a new thread for the same thing,
    why you continue to post partial procedures when you were asked to provide the whole thing for this problem (and please use code tags for code)
    why you didn't confirm the actual values that your variables return (in the other thread when asked to, or here),
    why posted code that uses a wild card and finds a file regardless of its extension (at least mine did) received no comment from you at all.
    If I have overlooked a detail and stated something that's not accurate because I'm not going to scour the other thread, I apologize in advance.
    Hope someone can come through for you - seems I failed.
    Last edited by Micron; 05-20-2018 at 09:40 PM. Reason: clarification & added info

  3. #3
    lawdy is offline Competent Performer
    Windows 7 32bit Access 2013
    Join Date
    Jan 2013
    Posts
    172
    I was not getting anywhere on the other thread. I thought I wasn't explaining the problem. I will not post anymore if I am brothering you

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,892
    In the other thread, I provided the direction for a solution with a link to Allen Browne's sample code that shows how to loop through a folder and reference files that match a search template. It is the only way to 'grab' multiple files using wildcard. Here is that link again: http://allenbrowne.com/ser-59.html

    If you know there is only a single file with an unknown extension, then Dir() function can be used to set a variable with that file name.

    I just noticed you are using the wrong variable in the Attachment.Add command. Need the variable that holds the actual extension as returned by the Dir() function. Change to:

    olMailItem.Attachments.Add strSitePlanLoc & strFileName



    That other thread was marked solved so I assumed the information was satisfactory. Again, this thread is already marked solved.
    Last edited by June7; 05-21-2018 at 04:11 AM.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,776
    Quote Originally Posted by lawdy View Post
    I was not getting anywhere on the other thread.
    Do continue to post, but know that the same core group of people are likely going to be the ones that will respond, or at least follow a thread. Also know the rules on posting re: the same problem and posting the same problem in other forums. That and actually acknowledging an answer shows respect and consideration for someone's effort. It's when I post a solution, ask a question, provide direction, etc. and it's all ignored - that's what is frustrating. If you don't understand what you've been asked or provided, then seek clarification and don't just ignore the questions/suggestions/requests. You are here because you need help. I know there are others whom I've helped that would tell you that I have put many hours into a solution - not because they were my friends, but because they worked with me. I'd say getting help here is usually a 2 sided proposition and you need to do your part.

    That being said, if you want to post a compacted and zipped copy of your db with whatever forms/tables/queries are required to work with the problem, then that might be your best bet. Otherwise, review the other thread and try to apply the suggestions that were given. June7's comments regarding multiple files are valid, but unless I'm mistaken, you have clearly stated that while a certain file name might have one of several possible extensions, there is only ever 1 file by a particular name. Therefore, the extension doesn't matter as long as you're happy if the code returns the first (or only) one that it finds by a certain name. The example I provided was tested thusly:

    - created a file, wrote the procedure, provided a folder path to a variable
    - provided a file name (forum1) to a variable, including the extension for that file (jpg)
    - tested, OK.
    - modified to use * wildcard for extension, tested again, looking for forum1.*, worked OK (found forum1.jpg)
    - created a new file, forum1.gif, ran same code, worked OK (found forum1.gif)
    If that's not what you're after, then I'm lost. Perhaps this
    Below is my code which does not return anything
    isn't the problem, because you also state
    but no file is attached.
    which isn't the same thing. I don't seem to know what the issue is any more. Maybe I never did.
    Last edited by Micron; 05-21-2018 at 07:00 AM. Reason: clarification

  6. #6
    orange's Avatar
    orange is offline Moderator
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,722
    lawdy ( or others)

    Why is this thread marked solved? Did you actually find a solution? If so, please tell readers what it was/is.

    Lawdy, there is no need to start a new thread --same title, same continuing issue. Readers are here to help, so you are not "bothering" us provided you are trying to use the advice offered and giving an honest try.

    Should the threads be merged?

    When you say
    I was not getting anywhere on the other thread. I thought I wasn't explaining the problem. I will not post anymore if I am brothering you
    , it is time to go back to basics :

    In order to assist a poster with an issue, it is necessary to understand the issue and the context clearly. This is often accomplished by providing a description of the "business" in clear, simple English (no jargon) showing us "what" you are trying to support. Then readers can offer opinions, advice, assistance as to "how" it may be achieved with Access.

    Good luck with your project.

  7. #7
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,892
    Solution is post 4.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  8. #8
    orange's Avatar
    orange is offline Moderator
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,722
    Thanks June, but was it you or Lawdy who marked it solved. I'm nor certain that Lawdy has "received/understood" since he/she has not responded (that I can see).

  9. #9
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,892
    Not me. I think Lawdy did it here and the other thread.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

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

Similar Threads

  1. wildcard charcters
    By lawdy in forum Programming
    Replies: 19
    Last Post: 05-21-2018, 04:11 AM
  2. Wildcard seacrh
    By andyt_2005 in forum Forms
    Replies: 4
    Last Post: 08-02-2014, 02:30 PM
  3. Using a wildcard if an IIF statement.
    By atlee in forum Programming
    Replies: 6
    Last Post: 02-23-2014, 04:02 PM
  4. Replies: 9
    Last Post: 12-05-2013, 11:48 AM
  5. Querying a wildcard
    By undee69 in forum Queries
    Replies: 1
    Last Post: 10-15-2012, 06:00 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