rsbutterfly16
IS-IT--Management
hi guys. i hope you can help me, i am trying to create a delete button in my form. Basically what this form has to do is delete the row from my main table and then insert that row into my history table.
Main Table:
tblDetails
DistID (PK)
SalesNumber
SalesStatus (is always active)
Notes
tblHistory (History Table):
HistID (PK)
DistID (FK)
oldSalesNumber
SalesStatus (is always inactive)
OldNOtes
Date Changed
this is the code i have so far.....
Private Sub Label26_Click()
Dim dbs As DAO.Database
Dim strSQL As String
Dim strSQL2 As String
strSQL = "Delete tblDetails FROM tblDetails " & _
"values ('" & Me.cboSales.Value & "' , '" & Me.txtNotes.Value & "');"
'" WHERE DistID = (" & Me.txtDistID.Value & " );"
MsgBox strSQL
CurrentDb.Execute strSQL, dbFailOnError
strSQL2 = "Insert into tblsHistory (DistDetailsID, oldSalesNumber,OldNotes, DateChanged) " & _
"values (" & Me.txtDistID.Value & " ,'" & Me.cboSales.Value & "' , '" & Me.txtNotes.Value & "', #" & Now() & "#);"
MsgBox strSQL2
CurrentDb.Execute strSQL, dbFailOnError
but i keep getting an error "syntax error in from clause
Main Table:
tblDetails
DistID (PK)
SalesNumber
SalesStatus (is always active)
Notes
tblHistory (History Table):
HistID (PK)
DistID (FK)
oldSalesNumber
SalesStatus (is always inactive)
OldNOtes
Date Changed
this is the code i have so far.....
Private Sub Label26_Click()
Dim dbs As DAO.Database
Dim strSQL As String
Dim strSQL2 As String
strSQL = "Delete tblDetails FROM tblDetails " & _
"values ('" & Me.cboSales.Value & "' , '" & Me.txtNotes.Value & "');"
'" WHERE DistID = (" & Me.txtDistID.Value & " );"
MsgBox strSQL
CurrentDb.Execute strSQL, dbFailOnError
strSQL2 = "Insert into tblsHistory (DistDetailsID, oldSalesNumber,OldNotes, DateChanged) " & _
"values (" & Me.txtDistID.Value & " ,'" & Me.cboSales.Value & "' , '" & Me.txtNotes.Value & "', #" & Now() & "#);"
MsgBox strSQL2
CurrentDb.Execute strSQL, dbFailOnError
but i keep getting an error "syntax error in from clause