Results 1 to 15 of 15
  1. #1
    gstylianou is offline Competent Performer
    Windows 7 32bit Access 2007
    Join Date
    Dec 2013
    Posts
    167

    Search on TextFile on C:

    Good evening,




    I need help on the following problem:
    I have a txt. file on path c:\ProgramData\Dab\Mod.txt which I store some numbers, one number per line. The numbers are usually not more than 10 digits and max 20 lines. In the database that makes i have the form (SKey) which includes the field ([txtSearch] in which a number is stored. I need lookup into a text file (Mod.txt) using a command button if the stored number exists. Please note that, in case where the number on field [txtSearch] exist into a txt File, i want to get back one related messeage..

    Is that possible to do?

    Regards

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,525
    Import the text file into a table, then search with a query.

  3. #3
    gstylianou is offline Competent Performer
    Windows 7 32bit Access 2007
    Join Date
    Dec 2013
    Posts
    167
    Hi Ramman,

    No, i must search directly into a text file my friend...Is that possible?

    Thanks

  4. #4
    ssanfu is offline Master of Nothing
    Windows XP Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Yes, you can do it.

    Haven't tried it, but you should be able to link to a text file just like you can link to an Excel file. Then use a query to search for a number.

    Or I know you can use VBA to open the text file and read through the text file comparing numbers. VBA can return a message.

  5. #5
    gstylianou is offline Competent Performer
    Windows 7 32bit Access 2007
    Join Date
    Dec 2013
    Posts
    167
    Using VBA is it possible ?

  6. #6
    ssanfu is offline Master of Nothing
    Windows XP Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    For sure. I do it a lot.

    Open the text file
    Start a loop
    read a line
    compare
    if found display message. then exit loop
    loop until end of text file
    Close text file

    Easy-peasy-lemon-squeezy

  7. #7
    gstylianou is offline Competent Performer
    Windows 7 32bit Access 2007
    Join Date
    Dec 2013
    Posts
    167
    Morning ssanfu,

    Could you please give a sample code do to that because i'm not familiar with vba?

    Regards

  8. #8
    ssanfu is offline Master of Nothing
    Windows XP Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    See dB.
    There is no error handling.
    Assumes that there will be a text file named "Mod.txt" in path "c:\ProgramData\Dab".
    Can be modified to be able to pick the file in any location.
    Attached Files Attached Files

  9. #9
    gstylianou is offline Competent Performer
    Windows 7 32bit Access 2007
    Join Date
    Dec 2013
    Posts
    167
    ssanfu Thanks ,

    But i cannot open the db....i'm getting this error....

    Thanks again
    Attached Thumbnails Attached Thumbnails Picture21.png  

  10. #10
    ssanfu is offline Master of Nothing
    Windows XP Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Should be able to open it. It is A2007 format.

    Here is an A2000 format dB.

    "Me.TheNumber" is the name of the text box on the form.......
    Attached Files Attached Files

  11. #11
    gstylianou is offline Competent Performer
    Windows 7 32bit Access 2007
    Join Date
    Dec 2013
    Posts
    167
    Steve thank you very much,

    I open the db, and create the folder Dab as well as the text file Mod. I write into file the number 123456 but it does'n n work.!! Cannot find the number, actually cannot recognize it..
    Can we do something?

    Thanks in advanced

  12. #12
    ssanfu is offline Master of Nothing
    Windows XP Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    but it does'n n work.!!
    Exactly what "doesn't work"?? Error message?

    You have the path "c:\ProgramData\Dab"?

    Attached is the text file I used.
    Open the dB and enter one of the numbers from the text file into the text box. Click the button.

    If you still can't get a message to display, Post the "Mod.txt" file you are using.
    Attached Files Attached Files

  13. #13
    gstylianou is offline Competent Performer
    Windows 7 32bit Access 2007
    Join Date
    Dec 2013
    Posts
    167
    Good morning ssanfu,

    Of course i understand how it works my friend. First of all i have created the file into path and i put the sample number on it. Please note that, the numbers which i will put in this file are not only 10digits. Sometimes its necessary to put numbers with less 5digits.

    Anyway, i tried to put into file the sample number 1234567890 and code cannot regognize or find it. I will be glad if you have another 5min to check it and help me.

    Thanks again.

  14. #14
    ssanfu is offline Master of Nothing
    Windows XP Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    I made some modifications to the code... Try this
    Attached Files Attached Files

  15. #15
    gstylianou is offline Competent Performer
    Windows 7 32bit Access 2007
    Join Date
    Dec 2013
    Posts
    167
    Good morning ssanfu,

    You got the point.!!! The db working fine.!!

    Thank you very much again and i'm very glad for your help.


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

Similar Threads

  1. Replies: 8
    Last Post: 09-02-2015, 03:00 PM
  2. Replies: 1
    Last Post: 03-26-2015, 11:08 AM
  3. Replies: 3
    Last Post: 09-02-2013, 04:33 PM
  4. writing to textfile with string in " "
    By pradeep.sands in forum Forms
    Replies: 4
    Last Post: 07-17-2013, 09:51 AM
  5. Exporting 3 queries to 3 textfile
    By Grooz13 in forum Import/Export Data
    Replies: 4
    Last Post: 10-05-2010, 09:15 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