M
Mark Kubicki
I've got a simple command button on a subform to insert a new record into a
table that is the subform's data source; however, while I am able to select
the data (a file name and it's path) nothing is inserted... I suspect it's a
simple syntax error, but have had no luck in finding it...
the table being inserted into has these fields:
type text
printCatalogSheet yes/no
BaseCatalogSheet yes/no
CatalogSheetLink hyperlink
PrintOrder number
this is the code I am using:
' Displays the Office File Open dialog to choose a file name
With Application.FileDialog(3) ' 3 is a constant:
msoFileDialogFilePicker
.Title = "Select page"
.Filters.Add "All Files", "*.*"
.Filters.Add "JPGs", "*.JPG"
.FilterIndex = 4
.AllowMultiSelect = False
.InitialFileName = CurrentProject.path
result = .show
If (result <> 0) Then 'result = 0 if nothing was selected
CatalogSheetLink = Trim(.SelectedItems.Item(1))
Else
response = MsgBox("...nothing selected to add", vbInformation +
vbOKOnly, "IMAGE SELECTION ERROR")
End If
End With
Dim sSQL As String
sSQL = "INSERT INTO tbeAdditionalPages (type, printCatalogSheet,
BaseCatalogSheet, CatalogSheetLink) " & _
"VALUES ('" & Forms![frmSpec].[Type] & "', true, false,
CatalogSheetLink " & "';"
CurrentDb().Execute sSQL, dbFailOnError
many thanks in advance,
mark
table that is the subform's data source; however, while I am able to select
the data (a file name and it's path) nothing is inserted... I suspect it's a
simple syntax error, but have had no luck in finding it...
the table being inserted into has these fields:
type text
printCatalogSheet yes/no
BaseCatalogSheet yes/no
CatalogSheetLink hyperlink
PrintOrder number
this is the code I am using:
' Displays the Office File Open dialog to choose a file name
With Application.FileDialog(3) ' 3 is a constant:
msoFileDialogFilePicker
.Title = "Select page"
.Filters.Add "All Files", "*.*"
.Filters.Add "JPGs", "*.JPG"
.FilterIndex = 4
.AllowMultiSelect = False
.InitialFileName = CurrentProject.path
result = .show
If (result <> 0) Then 'result = 0 if nothing was selected
CatalogSheetLink = Trim(.SelectedItems.Item(1))
Else
response = MsgBox("...nothing selected to add", vbInformation +
vbOKOnly, "IMAGE SELECTION ERROR")
End If
End With
Dim sSQL As String
sSQL = "INSERT INTO tbeAdditionalPages (type, printCatalogSheet,
BaseCatalogSheet, CatalogSheetLink) " & _
"VALUES ('" & Forms![frmSpec].[Type] & "', true, false,
CatalogSheetLink " & "';"
CurrentDb().Execute sSQL, dbFailOnError
many thanks in advance,
mark