Run-Time Error 3146 ODBC Call Failed

G

Guest

iCan someone tell me how to change the code in the On Not In List event to
fix the Run-Time 3146 error that I am getting? I am attempting to add a new
record to a SQL table connected to a combo box while entering information for
a record.

The form record source is: SELECT dbo_uVOPMixingVessels.Location,
dbo_uVOPMixingVessels.Department, etc., and the table for the combo box to
which I am trying to add a record is:
SELECT dbo_uVOPMaterialConst.MatlConst FROM dbo_uVOPMaterialConst ORDER BY
[MatlConst].
dbo_uVOPMixingVessels.Baffles, dbo_uVOPMixingVessels.[Size of Prop2] FROM
dbo_uVOPMixingVessels WHERE
(((dbo_uVOPMixingVessels.Location)=Forms!frmMain!Location)).

This is the code in the On Not IN List event:

Private Sub Material_of_Construction_NotInList(NewData As String, Response
As Integer)
Dim Db As DAO.Database
Dim Rs As DAO.Recordset
Dim Msg As String

Msg = "'" & NewData & "' is not in the list." & vbCr & vbCr
Msg = Msg & "Do you want to add it?"
If MsgBox(Msg, vbQuestion + vbYesNo) = vbNo Then
Response = acDataErrContinue
MsgBox "Try again."
Else
Set Db = CodeDb
Set Rs = Db.OpenRecordset("dbo_uVOPMaterialConst", dbOpenDynaset)

Rs.AddNew
Rs![MatlConst] = NewData
Rs.Update
Response = acDataErrAdded

End If
End Sub


Thank you! Jani
 
G

Guest

Sorry - that would have been helpful information! Rs.Update

Rob Oldfield said:
Which line is it erroring on?


Jani said:
iCan someone tell me how to change the code in the On Not In List event to
fix the Run-Time 3146 error that I am getting? I am attempting to add a new
record to a SQL table connected to a combo box while entering information for
a record.

The form record source is: SELECT dbo_uVOPMixingVessels.Location,
dbo_uVOPMixingVessels.Department, etc., and the table for the combo box to
which I am trying to add a record is:
SELECT dbo_uVOPMaterialConst.MatlConst FROM dbo_uVOPMaterialConst ORDER BY
[MatlConst].
dbo_uVOPMixingVessels.Baffles, dbo_uVOPMixingVessels.[Size of Prop2] FROM
dbo_uVOPMixingVessels WHERE
(((dbo_uVOPMixingVessels.Location)=Forms!frmMain!Location)).

This is the code in the On Not IN List event:

Private Sub Material_of_Construction_NotInList(NewData As String, Response
As Integer)
Dim Db As DAO.Database
Dim Rs As DAO.Recordset
Dim Msg As String

Msg = "'" & NewData & "' is not in the list." & vbCr & vbCr
Msg = Msg & "Do you want to add it?"
If MsgBox(Msg, vbQuestion + vbYesNo) = vbNo Then
Response = acDataErrContinue
MsgBox "Try again."
Else
Set Db = CodeDb
Set Rs = Db.OpenRecordset("dbo_uVOPMaterialConst", dbOpenDynaset)

Rs.AddNew
Rs![MatlConst] = NewData
Rs.Update
Response = acDataErrAdded

End If
End Sub


Thank you! Jani
 
G

Guest

Yeah! Found the problem. In the sql table I had a mod_insertdate field that I
was not populating. Thanks for trying to figure this out - I now have it
working. Jani

Jani said:
Sorry - that would have been helpful information! Rs.Update

Rob Oldfield said:
Which line is it erroring on?


Jani said:
iCan someone tell me how to change the code in the On Not In List event to
fix the Run-Time 3146 error that I am getting? I am attempting to add a new
record to a SQL table connected to a combo box while entering information for
a record.

The form record source is: SELECT dbo_uVOPMixingVessels.Location,
dbo_uVOPMixingVessels.Department, etc., and the table for the combo box to
which I am trying to add a record is:
SELECT dbo_uVOPMaterialConst.MatlConst FROM dbo_uVOPMaterialConst ORDER BY
[MatlConst].
dbo_uVOPMixingVessels.Baffles, dbo_uVOPMixingVessels.[Size of Prop2] FROM
dbo_uVOPMixingVessels WHERE
(((dbo_uVOPMixingVessels.Location)=Forms!frmMain!Location)).

This is the code in the On Not IN List event:

Private Sub Material_of_Construction_NotInList(NewData As String, Response
As Integer)
Dim Db As DAO.Database
Dim Rs As DAO.Recordset
Dim Msg As String

Msg = "'" & NewData & "' is not in the list." & vbCr & vbCr
Msg = Msg & "Do you want to add it?"
If MsgBox(Msg, vbQuestion + vbYesNo) = vbNo Then
Response = acDataErrContinue
MsgBox "Try again."
Else
Set Db = CodeDb
Set Rs = Db.OpenRecordset("dbo_uVOPMaterialConst", dbOpenDynaset)

Rs.AddNew
Rs![MatlConst] = NewData
Rs.Update
Response = acDataErrAdded

End If
End Sub


Thank you! Jani
 

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