not in list - add record to table not working

P

p-rat

I have the following code:

Private Sub Lease_Well_No_NotInList(NewData As String, Response As
Integer)
Dim sqlAddState As String, UserResponse As Integer
DoCmd.OpenForm "LeaseWellRRCNumber", , , , , acDialog

Beep
UserResponse = MsgBox("Do you want to add this value to the list?",
vbYesNo)
If UserResponse = vbYes Then
sqlAddState = "Insert Into dbo_leasewellRRCnumber
([Lease_Name]) values ('" & NewData & "')"
sqlAddState = "Insert Into dbo_leasewellRRCnumber ([RRC_ID])
values ('" & NewData & "')"
CurrentDb.Execute sqlAddState, dbFailOnError
Response = acDataErrAdded
Else
Response = acDataErrContinue
End If
End Sub

It is suppose to add a value to my linked table. I get the Run-time
error '3146' ODBC call failed. Would anyone know what I'm doing
wrong? I just made this a linked table to SQL backend. It was working
fine when it was just an Access table. I'm lost. There are only to
columns in the table "Lease_Name" and "RRC_ID". I re-did my query and
have the correct record sources.

I'm definately a beginner and am lost. Any help would be great. Thanks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top