When attempting to run a Delete query via VBA based on a combobox, I'm getting the following error:
"Object does not support this property or method"
I'm unable to find anything via search that says this is, or is not possible.
I currently have a simple form, with a combobox and a command button. The combobox is based on a query to select and group the filenames stored within a table. The user selects one of these filenames, and uses the command button. The command button runs a Delete query which should delete the records from the table. The error is all I get. When the delete query is run in SQL I get the correct results, but when I attempt to represent that string in VBA I think I may be losing something, or framing it incorrectly.
SQL Version from a regular query that I attempted to represent in VBA:
VBA Function attached to command button:
I also attempted to create a text box on the form and link it as a text string from the combobox, but I get the same results. Any Ideas?
"Object does not support this property or method"
I'm unable to find anything via search that says this is, or is not possible.
I currently have a simple form, with a combobox and a command button. The combobox is based on a query to select and group the filenames stored within a table. The user selects one of these filenames, and uses the command button. The command button runs a Delete query which should delete the records from the table. The error is all I get. When the delete query is run in SQL I get the correct results, but when I attempt to represent that string in VBA I think I may be losing something, or framing it incorrectly.
SQL Version from a regular query that I attempted to represent in VBA:
Code:
Delete *
FROM tblDrillStudyData
WHERE (((tblDrillStudyData.FileName)=[Forms].[frmRecordDelete].[cboFileName]));
VBA Function attached to command button:
Code:
Private Sub cmdDelRecSet_Click()
On Error GoTo Err_cmdDelRecSet_Click
Dim strQuery As String
strQuery = "DELETE * FROM [tblDrillStudyData] WHERE(((tblDrillStudyData.FileName) = '" & [Forms].[frmRecordDelete].[cboFileName] & "'));"
DoCmd.RunSQL strQuery
Exit_cmdDelRecSet_Click:
Exit Sub
Err_cmdDelRecSet_Click:
msgbox Err.Description, vbExclamation, "Error #" & Err.Number
Resume Exit_cmdDelRecSet_Click
End Sub
I also attempted to create a text box on the form and link it as a text string from the combobox, but I get the same results. Any Ideas?