add new row to a table
Hey guys,
I'm having a problem adding a new row of information to my table.
I've been switching a few things around, but I keep getting different errors.
My form takes 2 entries in textboxes (txtDesign2,JITL)
The table has 3 fields
I'm trying to make a new row at the bottom of the table with the
2 entries in their respective fields and set the other field to "Y"
The problem seems to be at mydb.OpenRecordset.
This is the code.
Private Sub btnSave_Click()
Dim mydb As Database
Dim mytable As Recordset
Dim route As String
Dim Design As String
route = Me![JITL]
Design = Me![txtDesign2]
If route <> "20" And route <> "40" Then
MsgBox """Invalid JITL...Please Re-Enter""", vbOKOnly, ""
Else
DoCmd.SetWarnings False
Set mydb = (DBEngine.Workspaces(0).Databases(0))
Set mytable = mydb.OpenRecordset("T_new_thermo_order", dbOpenDynaset)
mytable.AddNew
mytable("dsn_nbr") = Me![txtDesign2]
mytable("jitl") = Me![JITL]
mytable("order_typ") = "Y"
mytable.Update
mytable.Close
mydb.Close
DoCmd.Close acForm, "frm_New Order"
End If
End Sub
Thanks for any help,
Dave
|