I use the following code in an unbound form to add a new record to a table. I have just converted my Access back-end to SQL and this no longer works. So now I have an Access front-end with a SQL Server back-end. Can someone tell me what I need to change to make this work? I am assuming it has to do with my dim and set statements, but not positive.
Thanks for your help.
Dim cnCurrent As ADODB.Connection
Dim rsComm As ADODB.Recordset
Set cnCurrent = CurrentProject.Connection
Set rsComm = New ADODB.Recordset
rsComm.Open "dbo_tblRepCommissions", cnCurrent, , adLockOptimistic, adCmdTable
With rsComm
.AddNew
![RepNo] = RepNo.Value
![ProductType] = ProductType.Value
![Rate] = Rate.Value
![ProductDescription] = ProductDescription.Value
![Amount] = Amount.Value
![ClientName] = ClientName.Value
![CommissionType] = CommissionType.Value
![Source] = "Manual Input"
![Date] = CommDate.Value
.Update
Label36_Click
MsgBox ("The commission has been entered."
, , "Message Alert"
End With
End If
rsComm.Close
cnCurrent.Close
Set rsComm = Nothing
Set cnCurrent = Nothing
Thanks for your help.
Dim cnCurrent As ADODB.Connection
Dim rsComm As ADODB.Recordset
Set cnCurrent = CurrentProject.Connection
Set rsComm = New ADODB.Recordset
rsComm.Open "dbo_tblRepCommissions", cnCurrent, , adLockOptimistic, adCmdTable
With rsComm
.AddNew
![RepNo] = RepNo.Value
![ProductType] = ProductType.Value
![Rate] = Rate.Value
![ProductDescription] = ProductDescription.Value
![Amount] = Amount.Value
![ClientName] = ClientName.Value
![CommissionType] = CommissionType.Value
![Source] = "Manual Input"
![Date] = CommDate.Value
.Update
Label36_Click
MsgBox ("The commission has been entered."
End With
End If
rsComm.Close
cnCurrent.Close
Set rsComm = Nothing
Set cnCurrent = Nothing