Ok here is the situation, I was tring to build a form to input several items into a single new record. The form was very long and tedious so i broke it up into several forms. Now I have all these nice little forms but they each start a new record which defeats the purpose. So i looked in an existing database we have here and was looking to see how someone else did it. This is the code i got from there button on the form:
Private Sub Button6_Click()
On Error GoTo Err_Button6_Click
Dim DocName As String
Dim LinkCriteria As String
Dim Order As Recordset
Dim DB As Database
Set DB = DBEngine.Workspaces(0).Databases(0)
Set Order = DB.OpenRecordset("Main_Order_Table", DB_OPEN_DYNASET, DB_APPENDONLY)
Order.AddNew
Order!CustomerName = Field18
Order!CustomerAddress = Field8
Order!CustomerCity = Field10
Order!CustomerZip = Field14
Order.Update
DocName = "Sales_Rep_Choice"
DoCmd.Close
DoCmd.OpenForm DocName, , , LinkCriteria
Exit_Button6_Click:
Exit Sub
Err_Button6_Click:
MsgBox Error$
Resume Exit_Button6_Click
End Sub
looks simple doesnt it... i thought that as well so i modified it to meet my needs and here it is as follows:
Private Sub Command2_Click()
On Error GoTo Err_Command2_Click
Dim DocName As String
Dim LinkCriteria As String
Dim Order As Recordset
Dim DB As Database
Set DB = DBEngine.Workspaces(0).Databases(0)
Set Order = DB.OpenRecordset("Master Delivery Schedule", DB_OPEN_DYNASET, DB_APPENDONLY)
Order.AddNew
Order![Job Type] = Jobtype
Order.Update
DocName = "New Job Customer"
DoCmd.Close
DoCmd.OpenForm DocName, , , LinkCriteria
Exit_Command2_Click:
Exit Sub
Err_Command2_Click:
MsgBox Error$
Resume Exit_Command2_Click
End Sub
It throws me an error which says Compile Error: User-defined type not defined then it highlights Dim Db as Database in Blue then when i click ok it has an arrow and highlights "Private Sub Button6_Click()" in Yellow....... i have no hair left. Please help lol
Private Sub Button6_Click()
On Error GoTo Err_Button6_Click
Dim DocName As String
Dim LinkCriteria As String
Dim Order As Recordset
Dim DB As Database
Set DB = DBEngine.Workspaces(0).Databases(0)
Set Order = DB.OpenRecordset("Main_Order_Table", DB_OPEN_DYNASET, DB_APPENDONLY)
Order.AddNew
Order!CustomerName = Field18
Order!CustomerAddress = Field8
Order!CustomerCity = Field10
Order!CustomerZip = Field14
Order.Update
DocName = "Sales_Rep_Choice"
DoCmd.Close
DoCmd.OpenForm DocName, , , LinkCriteria
Exit_Button6_Click:
Exit Sub
Err_Button6_Click:
MsgBox Error$
Resume Exit_Button6_Click
End Sub
looks simple doesnt it... i thought that as well so i modified it to meet my needs and here it is as follows:
Private Sub Command2_Click()
On Error GoTo Err_Command2_Click
Dim DocName As String
Dim LinkCriteria As String
Dim Order As Recordset
Dim DB As Database
Set DB = DBEngine.Workspaces(0).Databases(0)
Set Order = DB.OpenRecordset("Master Delivery Schedule", DB_OPEN_DYNASET, DB_APPENDONLY)
Order.AddNew
Order![Job Type] = Jobtype
Order.Update
DocName = "New Job Customer"
DoCmd.Close
DoCmd.OpenForm DocName, , , LinkCriteria
Exit_Command2_Click:
Exit Sub
Err_Command2_Click:
MsgBox Error$
Resume Exit_Command2_Click
End Sub
It throws me an error which says Compile Error: User-defined type not defined then it highlights Dim Db as Database in Blue then when i click ok it has an arrow and highlights "Private Sub Button6_Click()" in Yellow....... i have no hair left. Please help lol