J
Jani
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
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