Code:
Private Sub cmdDeleteRecord_Click()
On Error GoTo ProcError
Dim db As DAO.Database
Dim strSQL As String
Dim lngBookID As Long
Set db = CurrentDb()
lngBookID = Nz(Me.txtpkBookId, 0)
' lngBookID = [Forms]![frmBooks]![txtpkBookId] 'Or lngBookID = Me.txtpkBookId.
If lngBookID = 0 Then
MsgBox "Missing Book ID"
Else
'lngBookID <> 0
strSQL = "INSERT INTO tblDeletedBooks (pkBookId, BookTitle, Subtitle, ISBNNumber, DateRegistered, EditionNumber, VolumeNumber,"
strSQL = strSQL & " CallNumberNum, CallNumberText, NumberOfPages, YearPublished, MemComments, fkcategoryId, fkformatId, fkPublisherId, fkLanguageId, fkSeries) "
strSQL = strSQL & " SELECT pkBookId, BookTitle, Subtitle, ISBNNumber, DateRegistered, EditionNumber, VolumeNumber, CallNumberNum, CallNumberText, NumberOfPages,"
strSQL = strSQL & " YearPublished, MemComments, fkcategoryId, fkformatId, fkPublisherId, fkLanguageId, fkSeries "
strSQL = strSQL & " FROM qryBooks "
strSQL = strSQL & " WHERE [pkBookId] = " & lngBookID
Debug.Print "lngBookID: " & lngBookID
Debug.Print "strSQL =" & vbCrLf & strSQL
'execute the SQL
db.Execute strSQL, dbFailOnError
End If
ExitProc:
Set db = Nothing
Exit Sub
ProcError:
MsgBox "Error " & Err.Number & ": " & Err.Description & ", " & vbCritical, "Message Box Title Text"
Resume ExitProc
End Sub
Private Sub cmdDeleteRecord_Click()
On Error GoTo ProcError
Dim db As DAO.Database
Dim strSQL As String
Dim lngBookID As Long
Set db = CurrentDb()
lngBookID = Nz(Me.txtpkBookId, 0)
' lngBookID = [Forms]![frmBooks]![txtpkBookId] 'Or lngBookID = Me.txtpkBookId.
If lngBookID = 0 Then
MsgBox "Missing Book ID"
Else
'lngBookID <> 0
strSQL = "INSERT INTO tblDeletedBooks (pkBookId, BookTitle, Subtitle, ISBNNumber, DateRegistered, EditionNumber, VolumeNumber,"
strSQL = strSQL & " CallNumberNum, CallNumberText, NumberOfPages, YearPublished, MemComments, fkcategoryId, fkformatId, fkPublisherId, fkLanguageId, fkSeries) "
strSQL = strSQL & " SELECT pkBookId, BookTitle, Subtitle, ISBNNumber, DateRegistered, EditionNumber, VolumeNumber, CallNumberNum, CallNumberText, NumberOfPages,"
strSQL = strSQL & " YearPublished, MemComments, fkcategoryId, fkformatId, fkPublisherId, fkLanguageId, fkSeries "
strSQL = strSQL & " FROM qryBooks "
strSQL = strSQL & " WHERE [pkBookId] = " & lngBookID
Debug.Print "lngBookID: " & lngBookID
Debug.Print "strSQL =" & vbCrLf & strSQL
'execute the SQL
db.Execute strSQL, dbFailOnError
End If
ExitProc:
Set db = Nothing
Exit Sub
ProcError:
MsgBox "Error " & Err.Number & ": " & Err.Description & ", " & vbCritical, "Message Box Title Text"
Resume ExitProc
End Sub