Users to drag and drop image into form

  • I am trying to allow users to drag an Acrobat file (from a folder on their computer) to a bound object frame (named 'Document') on a form. After they "drag and drop" this file, they will be able to click the "Add Document" button and this document will be attached to a specific record in the table. The trouble I seem to be having is that it doesn't like the type 'adVarBinary' (shown in red in the "Add Button" code below). What type should this Document be input as?

    Code:


     
    Private Sub btnAddDocument_Click()
    
        Dim Cmd As New ADODB.Command
        Dim Prm As New ADODB.Parameter
        
        With Cmd
             .ActiveConnection = CurrentProject.Connection
             .CommandText = "dbo.pr_ProjectAddDocument"
             .CommandType = adCmdStoredProc
             Set Prm = Cmd.CreateParameter("@Project_Key", adInteger, adParamInput, , Me.Project_Key)
             .Parameters.Append Prm
             Set Prm = Cmd.CreateParameter("@Document", adVarBinary, adParamInput, 8000, Me.Document)
             .Parameters.Append Prm
             .Execute
         End With
    
    End Sub
    
     

    Here is the code for my stored procedure to help out as well:

    Code:


     
    CREATE PROCEDURE dbo.pr_ProjectAddDocument
    (@Project_Key int,
    @Document varbinary(8000))
    
    AS
    
    DECLARE @RC as tinyint
    
    SELECT Project_Key
    FROM tblDocuments
    WHERE Project_Key = @Project_Key
    
    SELECT @RC = @@Rowcount
    
    If @RC >0
      Begin
    UPDATE tblDocuments
    SET Document = @Document
    WHERE Project_Key = @Project_Key
      End
    Else
      Begin
    INSERT INTO tblDocuments(Project_Key, Document)
    VALUES (@Project_Key, @Document)
      End
    GO 
     

  • image

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply