Hi All.
I've updated my DB from Office 2010 to 365 and the accmddeleterecord is no longer working.
When a user creates a record for a device, code runs to check whether there is already an outstanding record for the same device. If there is an outstanding job, the user is then prompted whether to abort the current job.
This is done using the following code:
When I run the code I get a message stating "Run-time error 2046 - The command or action 'DeleteRecord' isn't available now."
When I debug the code it is only the following part that it is unhappy with:
RunCommand acCmdDeleteRecord
I have read through a few threads and found somebody suggesting the following solution:
CurrentDb.Execute "DELETE FROM table WHERE rowID = " & me.RowID
My table is called Assignment Ledger 2
My RowID is called Job No
Therefore I replaced RunCommand acCmdDeleteRecord with CurrentDb.Execute "DELETE FROM Assignment Ledger 2 WHERE Job No = " & me.Job_No
This then gives me the following message - Run-time error 3131: Syntax error in FROM clause.
Does anybody have any experience with this?
Thanks all
I've updated my DB from Office 2010 to 365 and the accmddeleterecord is no longer working.
When a user creates a record for a device, code runs to check whether there is already an outstanding record for the same device. If there is an outstanding job, the user is then prompted whether to abort the current job.
This is done using the following code:
Code:
Dim db As Database
Dim REC As Recordset
Dim Response, Message, Style, Title
Dim TotalRecords As Integer
Dim n As Integer
Dim strJobNo As String
Dim strCodeNo As String
Dim strSql As String
Dim strJobStatus As String
'Disregard Code Number = NONE
strCodeNo = Me![Code No]
If strCodeNo = "NONE" Then GoTo Exit_Code_BeforeUpdate
' Count duplicate records
strSql = "SELECT * From JobsNotDone WHERE [Code No] = " & "'" & Me![Code No] & "'"
Set db = CurrentDb()
Set REC = db.OpenRecordset(strSql, dbOpenSnapshot)
TotalRecords = REC.RecordCount
If TotalRecords = 0 Then REC.Close: GoTo Exit_Code_BeforeUpdate
REC.MoveLast
TotalRecords = REC.RecordCount
strJobNo = REC("Job No")
strJobStatus = REC("Job Status")
REC.Close
HandleDuplicates:
Message = "This Device is already booked on the system as Job No " & strJobNo & " Job Status is: " & strJobStatus
Title = "Job Duplicate Warning"
Response = MsgBox(Message, vbAbortRetryIgnore, Title)
If Response = vbIgnore Then GoTo Exit_Code_BeforeUpdate
If Response = vbRetry Then GoTo Exit_Retry
RunCommand acCmdDeleteRecord
DoCmd.Close acForm, "AssignmentLedgerEdit", acSaveNo
Exit_Code_BeforeUpdate:
Exit Sub
Exit_Retry:
Code.SetFocus
Code = "NONE"
SendKeys "+{TAB}", False
Exit Sub
When I run the code I get a message stating "Run-time error 2046 - The command or action 'DeleteRecord' isn't available now."
When I debug the code it is only the following part that it is unhappy with:
RunCommand acCmdDeleteRecord
I have read through a few threads and found somebody suggesting the following solution:
CurrentDb.Execute "DELETE FROM table WHERE rowID = " & me.RowID
My table is called Assignment Ledger 2
My RowID is called Job No
Therefore I replaced RunCommand acCmdDeleteRecord with CurrentDb.Execute "DELETE FROM Assignment Ledger 2 WHERE Job No = " & me.Job_No
This then gives me the following message - Run-time error 3131: Syntax error in FROM clause.
Does anybody have any experience with this?
Thanks all