Thanks
Expand|Select|Wrap|Line Numbers
- '---------------------------------
- 'Declaration of the variables
- '---------------------------------
- Dim rs As Recordset 'recordset use to get the objectId of the current record
- Dim QuerySelect As String 'represents the query to gather info
- Dim ObjectID As String 'represents the deleted objectId
- '--------------------------------
- 'End of declaration
- '--------------------------------
- 'Close the RecordControlBox
- DoCmd.Close acForm, "frmRecordControlBox"
- 'Retrieving data from the record to be deleted
- QuerySelect = "Select ObjectID From Description where Description.[Accession Number] = '" & Forms!frmDescription!txtAccNum.Value & "'"
- Set rs = CurrentDb().OpenRecordset(QuerySelect)
- 'going to the last record then come back to the first to make RS.RecordCount effective
- rs.MoveLast
- rs.MoveFirst
- 'check if there is only 1 record, should not delete a whole bunch of record at the same time
- If rs.RecordCount = 1 Then
- ObjectID = CStr(rs![ObjectID])
- 'building all the queries to delete every objectId in every table
- CurrentDb().Execute ("DELETE FROM [Condition Info] WHERE [Condition Info].[ObjectID]= " + ObjectID)
- CurrentDb().Execute ("DELETE FROM [Treatment Info] WHERE [Treatment Info].[ObjectID]= " + ObjectID)
- CurrentDb().Execute ("DELETE FROM [DigitalImageDetails] WHERE [DigitalImageDetails].[ObjectID]= " + ObjectID)
- Forms!frmDescription!rcdcontrol.SetFocus
- DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
- DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70
- Else
- MsgBox "An error occured while retrieving ObjectID of the artifact. No record have been deleted"
- End If
- Exit_rcdelete_Click:
- Exit Sub
- Err_rcdelete_Click:
- 'MsgBox Err.Description + "kgkgkg"
- Resume Exit_rcdelete_Click
- End Sub