Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.
'Function to Store Image File into a field of a recordset Public Function LoadFieldFromFile(rsf As ADODB.Field, str_full_path As String) On Error GoTo Er Dim fds As ADODB.Stream LoadFieldFromFile = False Set fds = New ADODB.Stream 'Make it a binary type fds.Type = adTypeBinary 'Open the stream fds.Open ' '*** Read the binary file into the stream buffer *** ' fds.LoadFromFile str_full_path ' save binary data into Field of current record rsf = fds.Read LoadFieldFromFile = True Done: fds.Close Set fds = Nothing Exit Function Er: Select Case Err.Number Case 3002 MsgBox "Could not read file (" & str_full_path & ") , check the path or the file may be in use." Case Else: 'Unexpected, fail with message box MsgBox "Error # " & Err.Number & "--" & Error, vbCritical, "LoadFieldFromFile()" End Select Resume Done End Function 'Sub in Form Private Sub cmdAttPic_Click() MsgBox "Note: You can only add one picture at a time.", vbInformation Dim str_full_path As String Dim fd As FileDialog Set fd = Application.FileDialog(msoFileDialogFilePicker) Dim vrtSelectedItem As Variant With fd If .Show = -1 Then For Each vrtSelectedItem In .SelectedItems str_full_path = vrtSelectedItem Next vrtSelectedItem Else End If End With Set fd = Nothing Dim intFKForm As Integer intFKForm = DLookup("PK_Form", "ztblForm", "Form_Name='" & Me.FormName & "'") Dim rs As ADODB.Recordset Dim Sql As String Dim FileName As String Set rs = New ADODB.Recordset Sql = "SELECT * FROM tblImage WHERE PK_Image = 0;" rs.Open Sql, CurrentProject.Connection, adOpenKeyset, adLockOptimistic, Options:=adCmdText rs.AddNew rs.Fields("FK_Form") = intFKForm rs.Fields("FK_ID") = Me.PK_HACCP rs.Fields("Act_Image_Date") = Date LoadFieldFromFile rs.Fields("Act_Image"), str_full_path rs.Fields("Act_Image_File_Name").Value = str_full_path rs.Update Dim intPicCnt As Integer intPicCnt = DCount("[PK_Image]", "tblImage", "[FK_Form]=" & intFKForm & " AND [FK_ID]=" & Me.PK_HACCP) Me.txtPicCnt = intPicCnt
|Subform Link field||13||22|
|Access VBA script to unzip a SQL Server backup file to a selected folder||12||23|
|MS Access Customer Order Pickers Picking List Auto Choose Locations||55||39|
|MS Access Delete Record If Is Null and Dirty After VBA Insert And Unique Index On. Duplication Error.||13||20|
Join the community of 500,000 technology professionals and ask your questions.
Connect with top rated Experts
24 Experts available now in Live!