Results 1 to 4 of 4

Thread: Alternative?

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2001
    Location
    Maumelle, AR
    Posts
    624

    Alternative?

    Is there a VB function to add information to a table in an access database? I'm using SQL right now, but it is such a pain! I can't add records to the table that contain "&". Like if I'm adding a string to say column "filname" in a table and the filename is "Huey Lewis & The News". Any suggestions appreciated.

  2. #2
    PowerPoster 2.0 Negative0's Avatar
    Join Date
    Jun 2000
    Location
    Southeastern MI
    Posts
    4,367
    Lets see your code, but your SQL string should look something like this:

    Code:
    strSQL = "INSERT INTO table1 (field1) VALUES ('" & text1.text & "')"
    objConn.execute strsql

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2001
    Location
    Maumelle, AR
    Posts
    624

    Here's part of it...

    This should be enough:
    VB Code:
    1. 'Store the info as strings
    2.     strFilepath = fname
    3.     strFileName = MusicMaster.File1.List(x)
    4.     strFileSize = FileLen(fname)
    5.     strTitle = RTrim(Songname)
    6.     strArtist = RTrim(Artist)
    7.    
    8.    
    9.    
    10. 'Use SQL to insert the information in the strings into the table
    11. SQL = "INSERT into " & table & "(FilePath, Filename, Filesize,
    12. _ Artist, Title) VALUES ('" _
    13. & Replace(strFilepath, "'", "''") & "','" _
    14. & Replace(strFileName, "'", "''") & "','" _
    15. & Replace(strFileSize, "'", "''") & "','" _
    16. & Replace(strArtist, "'", "''") & "','" _
    17. & Replace(strTitle, "'", "''") & "')"
    18.  
    19.  
    20. Cnn.Execute (SQL)
    21.  
    22. Next

  4. #4
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170
    I can't add records to the table that contain "&".
    I didn't understand this, even from your example. Can you give a more elaborate example.

    BTW, it SHOULD work. The code uve posted is fine.

Posting Permissions

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



Click Here to Expand Forum to Full Width