Please Help with Attaching a PDF to Form
Dear All,
I am still very new to any type of programming. The company I work is in education and I have been tasked with setting up a certificate request database.
I have an Access 2032 FE & SQL 2012 BE. I need to store PDF documents from all our branches.
I have been working on this for the past 3 working days and I have seen a great deal about saving the file path to the database vs saving the actual document in the DB. The documents would be located on each users computer.
I have a Form with all the information that is required by the certification department. On the form is a button (Called InsertID(ID in this case is the persons Identity Docuement)) and the button is linked to a table called dbo_CertificationSupportingDocuments. The table is referenced to the Main Certificate Request table.
The dbo_CertificationSupportingDocuments table is structured as follows:
When I click the button I get a Run Time error 3075 "Syntax error (Missing operator) in query operator.
The code I am using is:
I have been looking at this code for so long that I cannot see what is wrong. Please Please help
Regards
Azalea:banghead:
Dear All,
I am still very new to any type of programming. The company I work is in education and I have been tasked with setting up a certificate request database.
I have an Access 2032 FE & SQL 2012 BE. I need to store PDF documents from all our branches.
I have been working on this for the past 3 working days and I have seen a great deal about saving the file path to the database vs saving the actual document in the DB. The documents would be located on each users computer.
I have a Form with all the information that is required by the certification department. On the form is a button (Called InsertID(ID in this case is the persons Identity Docuement)) and the button is linked to a table called dbo_CertificationSupportingDocuments. The table is referenced to the Main Certificate Request table.
The dbo_CertificationSupportingDocuments table is structured as follows:
Code:
[CertSupportingDocID] [numeric](18, 0) IDENTITY(1,1) NOT NULL,
[CertificateRequestNumber] [numeric](18, 0) NOT NULL,
[RequestBlob] [varbinary](max) NULL,
[RequestFileName] [nvarchar](50) NULL,
[RequestFileExtension] [nchar](10) NULL,
[RequestFileMimeType] [nvarchar](50) NULL
When I click the button I get a Run Time error 3075 "Syntax error (Missing operator) in query operator.
The code I am using is:
Code:
Dim fd As FileDialog
Dim strFileWPath As String
Dim FileNoExt As String
Dim FileExt As String
Dim StrSQL As String
Dim db As Database
Dim CertFileName As String
Dim MFile As String
DoCmd.SetWarnings (WarningsOff)
Set fd = Application.FileDialog(msoFileDialogFilePicker)
fd.AllowMultiSelect = False
fd.Title = "Please Select the ID"
fd.Filters.Clear
fd.Filters.Add "Scan files", "*.pdf"
If fd.Show = True Then
If fd.SelectedItems(1) <> vbNullString Then
'CertFileName = fd.SelectedItems(1)
Me.FileName = fd.SelectedItems.Item(1)
End If
Else
'Exit code if no file is selected
End
End If
MFile = fd.SelectedItems(1)
CertFileName = Mid$(Me.FileName, InStrRev(Me.FileName, "\") + 1)
FileNoExt = Left$(CertFileName, InStrRev(CertFileName, ".") - 1)
FileExt = Right(Me.FileName, Len(Me.FileName) - InStrRev(Me.FileName, "."))
StrSQL = "INSERT INTO [dbo_CertificationSupportingDocuments]" & _
"([CertificateRequestNumber],[RequestBlob],[RequestFileName],[RequestFileExtension],[RequestFileMimeType]) VALUES " & _
"('" & (Me.RequestID) & "'," & MFile & ",'" & FileNoExt & "','" & FileExt & "', 'application/pdf')"
StrSQL = StrSQL
Debug.Print StrSQL
DoCmd.RunSQL (StrSQL)
I have been looking at this code for so long that I cannot see what is wrong. Please Please help
Regards
Azalea:banghead:
Last edited: