UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
3 Pages V < 1 2 3  (Go to first unread post)
   Reply to this topicStart new topic
> Storing Pictures In Access - How Big Can They Be?, Access 2016    
 
   
ADezii
post Sep 22 2019, 04:56 PM
Post#41



Posts: 2,680
Joined: 4-February 07
From: USA, Florida, Delray Beach


QUOTE
But then I get an error "item not found in collection" and rs![Item Name] = strFile is highlighted

This would usually indicate that [Item Name] is not a Field contained within the underlying Recordset (rs).
Go to the top of the page
 
ADezii
post Sep 22 2019, 06:21 PM
Post#42



Posts: 2,680
Joined: 4-February 07
From: USA, Florida, Delray Beach


As a test, I created a New SQL Server Database named BLOBs with a Table named tblInventoryPics. I then Linked to this Table and used the following Code to populate the only two Fields in tblInventoryPics ([InvID], [oPicture]{Image}). The Code worked as intended.
CODE
Dim strFile As String
Dim intCtr As Integer
Dim rstBLOB As ADODB.Recordset
Dim mstream As ADODB.Stream
Dim strFolder As String
Dim dlgOpen As Office.FileDialog
Dim intResponse As Integer
Dim intCtr2 As Integer

Set dlgOpen = Application.FileDialog(msoFileDialogFolderPicker)

With dlgOpen
  .AllowMultiSelect = False
  .ButtonName = "Select Import Folder"
  .Title = "Browse for Folders"
  .InitialView = msoFileDialogViewLargeIcons
  .InitialFileName = "C:\"
    If .Show <> -1 Then Exit Sub
      If .SelectedItems(1) = "C:\" Then
        strFolder = .SelectedItems(1)
      Else
        strFolder = .SelectedItems(1) & "\"
      End If
End With

intResponse = MsgBox("Import Graphics from " & strFolder & "?", vbQuestion + vbYesNo, "Import Prompt")
If intResponse = vbNo Then Exit Sub

Set rstBLOB = New ADODB.Recordset
rstBLOB.Open "dbo_tblInventoryPics", CurrentProject.Connection, adOpenDynamic, adLockOptimistic

intCtr = 1
strFile = Dir(strFolder & "*", vbNormal)

Set mstream = New ADODB.Stream

Do While strFile <> ""
  If fIsGraphicFile(strFile) Then
   intCtr2 = intCtr2 + 1
    With mstream
      .Type = adTypeBinary
      .Open
      .LoadFromFile strFolder & strFile
    End With
    With rstBLOB
      .AddNew
        .Fields("InvID").Value = intCtr
        .Fields("oPicture").Value = mstream.Read
      .Update
    End With
    mstream.Close: intCtr = intCtr + 1
  End If
    strFile = Dir
Loop

This post has been edited by ADezii: Sep 22 2019, 06:21 PM
Go to the top of the page
 
ordnance1
post Sep 22 2019, 07:54 PM
Post#43



Posts: 685
Joined: 7-May 11



Thank you Sir. Your first reply got me there. Seems when I setup the table in SQL Server I made a subtle change to 2 of the field names. I dropped the space between the words ItemName and ItemDescription but did not notice the space existed in the code. Sorry for wasting your time on that one.
Go to the top of the page
 
ADezii
post Sep 23 2019, 07:26 AM
Post#44



Posts: 2,680
Joined: 4-February 07
From: USA, Florida, Delray Beach


QUOTE
Sorry for wasting your time on that one.

No problem at all. I am definitely not an expert on SQL Server but I do know that it is not particularly found of spaces in Field Names.
Go to the top of the page
 
3 Pages V < 1 2 3


Custom Search


RSSSearch   Top   Lo-Fi    24th October 2019 - 12:07 AM