I inherited a database originally created using Office 97, then migrated to Office 2003 then Office 2007. All has been working well in the database so I now want to put a SQL backend using the Access frontend. I have run into an issue and can’t figure out what the problem is. I get the error “Field cannot be updated”. Here is the code below with the problem pointing to: Me.DESC = rst!DESC
Private Sub cmbBarCode_AfterUpdate()
Dim dbs As Database
Dim rst As Recordset
Dim strSQL, DESC, strMsg As String
Dim PRICE As Integer
DoCmd.Hourglass True
Set dbs = CurrentDb()
Me.cmbBarCode = UCase(Me.cmbBarCode)
strSQL = "SELECT class,toolid,Desc, Price FROM [toolcls_Mob]"
strSQL = strSQL & " WHERE qty_tot > 0 and [barcode] = '" & Me.cmbBarCode & "' and status = 'A';"
Set rst = dbs.OpenRecordset(strSQL)
If Not rst.EOF Then
Me.CLASS = rst!CLASS
Me.ToolID = rst!ToolID
Me.DESC = rst!DESC
Me.PRICE = rst!PRICE
If IsNull(Me.ToolID) Then
Me.QTY_OL.SetFocus
Else
Me.QTY_OL = 1
DoCmd.GoToRecord , , acNewRec
End If
Else
Me.cmbBarCode.SetFocus
strMsg = "The barcode you entered does not exist or is checked out!"
If MsgBox(strMsg, vbOKOnly, "Error!") = vbOK Then
Me.Undo
End If
End If
DoCmd.Hourglass False
End Sub
I’m sure this issue is related to the SQL backend – but I’m not sure why. Can someone help please?
Private Sub cmbBarCode_AfterUpdate()
Dim dbs As Database
Dim rst As Recordset
Dim strSQL, DESC, strMsg As String
Dim PRICE As Integer
DoCmd.Hourglass True
Set dbs = CurrentDb()
Me.cmbBarCode = UCase(Me.cmbBarCode)
strSQL = "SELECT class,toolid,Desc, Price FROM [toolcls_Mob]"
strSQL = strSQL & " WHERE qty_tot > 0 and [barcode] = '" & Me.cmbBarCode & "' and status = 'A';"
Set rst = dbs.OpenRecordset(strSQL)
If Not rst.EOF Then
Me.CLASS = rst!CLASS
Me.ToolID = rst!ToolID
Me.DESC = rst!DESC
Me.PRICE = rst!PRICE
If IsNull(Me.ToolID) Then
Me.QTY_OL.SetFocus
Else
Me.QTY_OL = 1
DoCmd.GoToRecord , , acNewRec
End If
Else
Me.cmbBarCode.SetFocus
strMsg = "The barcode you entered does not exist or is checked out!"
If MsgBox(strMsg, vbOKOnly, "Error!") = vbOK Then
Me.Undo
End If
End If
DoCmd.Hourglass False
End Sub
I’m sure this issue is related to the SQL backend – but I’m not sure why. Can someone help please?