Page 1 of 2 12 LastLast
Results 1 to 15 of 18
  1. #1
    Join Date
    May 2011
    Location
    poway ca
    Posts
    38

    Unhappy Unanswered: need help with vb

    Trying to get the record names of an external (to access) file. What is the vb code i need? TIA
    Last edited by jtmedin; 05-06-11 at 17:12.

  2. #2
    Join Date
    Mar 2009
    Posts
    5,442
    Provided Answers: 14
    Quote Originally Posted by jtmedin View Post
    Trying to get the record names of an external (to access) file. What is the vb code i need? TIA
    Can you elaborate? What do you call "record names"?

    Usually data files are organized in rows (records) that can have a unique identifier (Identity field, Primary key). Each row comprises one or several columns (fields) that have an ordinal position and can have a name.

    How data is organised strongly depends on the file format. Which kind of external file are you talking about, what's its format (Access, Excel, Text, Paradox, DBase, SQL, XML...)?
    Have a nice day!

  3. #3
    Join Date
    Jun 2005
    Location
    Richmond, Virginia USA
    Posts
    2,763
    Provided Answers: 19
    As Sinndho suggests, you're going to have to do a much better job of explaining what you're trying to do, in order for anyone here to help you. Your original post simply makes no sense, as written.

    Linq ;0)>
    Hope this helps!

    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  4. #4
    Join Date
    May 2011
    Location
    poway ca
    Posts
    38
    Quote Originally Posted by Sinndho View Post
    Can you elaborate? What do you call "record names"?

    Usually data files are organized in rows (records) that can have a unique identifier (Identity field, Primary key). Each row comprises one or several columns (fields) that have an ordinal position and can have a name.

    How data is organised strongly depends on the file format. Which kind of external file are you talking about, what's its format (Access, Excel, Text, Paradox, DBase, SQL, XML...)?
    Here is the overview: I have a directory with filenames of scans. I want to pickup one scan & insert it into a form. The external file is a scan of a jpg picture. So i need the record name from the directory to get the jpg scan. Hope this clears up some of the fog i generated. TIA

  5. #5
    Join Date
    Mar 2009
    Posts
    5,442
    Provided Answers: 14
    I'm still not sure to understand your goal but if you want to import file name into a table (and later on do whatever you want with its contents, including using its data into a form), here's a solution.

    In this example, the Table that will contain the names of the files is named Tbl_Files and it has a column [FileName] that contains the full name of a file (Disk:\FullPath\FileName.Extension)in each row.
    Code:
    Function Fill_Tbl_Files(ByVal Folder As String, Optional ByVal Extension As String = "*")
    
        Const c_strSQL As String = "INSERT INTO Tbl_Files ( FileName ) VALUES ( '{@FileName}' );"
        Dim strFileName As String
        
        CurrentDb.Execute "DELETE FROM Tbl_Files;", dbFailOnError
        If Right(Folder, 1) <> "\" Then Folder = Folder & "\"
        strFileName = Dir(Folder & "*." & Extension)
        Do Until Len(strFileName) = 0
            CurrentDb.Execute Replace(c_strSQL, "{@FileName}", Folder & strFileName), dbFailOnError
            strFileName = Dir
        Loop
        
    End Function
    This function could for instance be called when the form that uses the Tbl_Files table opens.
    Have a nice day!

  6. #6
    Join Date
    May 2011
    Location
    poway ca
    Posts
    38
    Function Fill_Tbl_Files(ByVal Folder As String, Optional ByVal Extension As String = "*")

    Ok works fine. Only trouble i had was naming the table '_Tbl_files_' & 2007 didnt like that.
    Changed to 'Tbl_files' & every thing work great :-). Much Thanks
    Last edited by jtmedin; 05-09-11 at 23:35.

  7. #7
    Join Date
    May 2011
    Location
    poway ca
    Posts
    38
    Ok now i have failure with: .edit
    Interesting it doesn't complain about: .update when i comment out the .edit's

    I tried to use a ref: ms dao 3.6 but got a conflict with module or other ref.
    I must be using a nono name in the tables but unable to find it out. How do i find out what the conflict is?

    Any idea? TIA

  8. #8
    Join Date
    May 2011
    Location
    poway ca
    Posts
    38

    still more

    Ok this is what i have in the vb pgm:

    With altMembers

    .AddNew
    altMembers.Fields("front") = rstProj![FileNm]

    Here is where i need 'rstproj![filenm]' which is the pointer to the jpg file 'ie c:\tmp\file.jpg' to enter that picture into the "front" field.
    1. how do i get the jpg file instead of its pointer?
    2. how do i define the "front" field to receive the jpg picture?
    Any ideas? TIA

    .Fields("lastnm") = "addot" & intI
    .Fields("firstnm") = "first name" & intI
    .Fields("datehrd") = #12/5/1940#
    rstProj.MoveNext
    altMembers.Fields("back") = rstProj![FileNm]
    .Update
    rstProj.MoveNext ' should be pairs of jpg
    End With

  9. #9
    Join Date
    Mar 2009
    Posts
    5,442
    Provided Answers: 14
    1. It's strongly recommanded NOT to store the contents of graphic files into Access.

    2. If you really want to however, you can use a memo field.

    3. Wen you supply some code section, please supply it with enough information to be understandable: What's altMembers, how is it defined, how is it opened/affected?

    4. As far as I know, 'rstproj![filenm]' contains the name of a file, not a pointer to the file but maybe there's something I missed in your explanations.

    5. You should open a new thread when you ask a new question that's not closely related to the former one.
    Have a nice day!

  10. #10
    Join Date
    May 2011
    Location
    poway ca
    Posts
    38
    Sinndho;6503169]1. It's strongly recommanded NOT to store the contents of graphic files into Access.
    What do u suggest?

    2. If you really want to however, you can use a memo field.
    2007 has an attachment type

    3. Wen you supply some code section, please supply it with enough information to be understandable: What's altMembers, how is it defined, how is it opened/affected?
    Figured that was unnecessary since it was ok for receiving ...

    4. As far as I know, 'rstproj![filenm]' contains the name of a file, not a pointer to the file but maybe there's something I missed in your explanations.
    Figured the ie ... covered that

    5. You should open a new thread when you ask a new question that's not closely related to the former one.
    This is all part of the program sorry

  11. #11
    Join Date
    Mar 2009
    Posts
    5,442
    Provided Answers: 14
    Access does not handle very large files too well. That's why it's better to keep the graphic files outside the database and only store the file names.

    I did not know that you use Acc2007 (you did not mentioned it) and as Missinglinq stated out: "All posts/responses based on Access 2000/2003". Unless otherwise specified, this is true for many of us here as far as I know. Personaly I have several versions of Access installed but Acc2003 remains the default version I use.

    You complained about "Ok now i have failure with: .edit". It's difficult to figure out what happens with the method of an object if you don't know how it was created and instanciated. For example, if you open a DAO recordset this way:
    Code:
    Currentdb.OpenRecordSet("SomeTable", dbOpenSnapshot)
    it's easy to understand why the .Edit method will fail. There are many similar cases.

    Even if several questions are related to the same program it's better to open a distinct thread for each specific question because many people open the thread once and won't open it again if, for instance, they don't have an answer to the original question. If you post a different question in the same thread later on many people won't see it and you'll miss oportunities to receive a valuable answer.
    Have a nice day!

  12. #12
    Join Date
    May 2011
    Location
    poway ca
    Posts
    38

    syntax

    Quote Originally Posted by jtmedin View Post
    Ok this is what i have in the vb pgm:

    With altMembers

    .AddNew
    altMembers.Fields("front") = rstProj![FileNm]

    Here is where i need 'rstproj![filenm]' which is the pointer to the jpg file 'ie c:\tmp\file.jpg' to enter that picture into the "front" field.
    1. how do i get the jpg file instead of its pointer?
    2. how do i define the "front" field to receive the jpg picture?
    Any ideas? TIA

    .Fields("lastnm") = "addot" & intI
    .Fields("firstnm") = "first name" & intI
    .Fields("datehrd") = #12/5/1940#
    rstProj.MoveNext
    altMembers.Fields("back") = rstProj![FileNm]
    .Update
    rstProj.MoveNext ' should be pairs of jpg
    End With
    There must be some syntax for 'rstproj![filenm]' to pick up the picture not the pointer to the picture.

  13. #13
    Join Date
    May 2011
    Location
    poway ca
    Posts
    38
    Quote Originally Posted by Sinndho View Post
    Access does not handle very large files too well. That's why it's better to keep the graphic files outside the database and only store the file names.

    I did not know that you use Acc2007 (you did not mentioned it) and as Missinglinq stated out: "All posts/responses based on Access 2000/2003". Unless otherwise specified, this is true for many of us here as far as I know. Personaly I have several versions of Access installed but Acc2003 remains the default version I use.

    You complained about "Ok now i have failure with: .edit". It's difficult to figure out what happens with the method of an object if you don't know how it was created and instanciated. For example, if you open a DAO recordset this way:
    Code:
    Currentdb.OpenRecordSet("SomeTable", dbOpenSnapshot)
    it's easy to understand why the .Edit method will fail. There are many similar cases.

    Even if several questions are related to the same program it's better to open a distinct thread for each specific question because many people open the thread once and won't open it again if, for instance, they don't have an answer to the original question. If you post a different question in the same thread later on many people won't see it and you'll miss oportunities to receive a valuable answer.
    I opened it with:Currentdb.OpenRecordSet("SomeTable", dbOpenDynaset)

  14. #14
    Join Date
    Mar 2009
    Posts
    5,442
    Provided Answers: 14
    To display a picture on a form you can use an Image control. This control has a Picture property. When you set the value of this property to the name of a picture file, the control displays the image. You don't need to open the file and use a pointer to it. This works with bitmap pictures.

    If the picture is not stored in a bitmap file, you'll need to use another kind of control but the principle of use remains the same most of the time.

    If it's not its name, I still don't understand what you mean by pointer to a file when you write:
    There must be some syntax for 'rstproj![filenm]' to pick up the picture not the pointer to the picture.
    Have a nice day!

  15. #15
    Join Date
    May 2011
    Location
    poway ca
    Posts
    38
    Sinndho, Ah there u are. Thanks for the function which works fine with directories on the c drive but not when i specify a directory on a network hd. I single stepped ur sql & every thing looks ok until i get past the strfilename statement. Strfilename has the complete path to the network hd via Desktop. But the do statement acts like the len of strfilename is 0 :-(. Any ideas? TIA
    Last edited by jtmedin; 06-08-11 at 22:32.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •