I have a main form that displays all the information and lists all the ordered items. Clicking a button on the form opens a new form where a new item can be added. This works fine, but when Add Item is clicked on the second form the record is added and the form is then closed. But I also send a requery method to the main form to update the list of ordered items. This doesn't update the list with the new item. But I've added a temporary button on the main form that sends the command Me.Requery and if I wait 2-3 seconds after adding the item it is displayed.
The code in the Add Item button is -
Private Sub cmdAdd_Click()
Dim total As Currency
Dim dbOrders As Database
Dim rsOrders As DAO.Recordset
total = Me.txtCost * Me.txtQuantity
Set dbOrders = OpenDatabase(Application.CurrentProject.Path & "\Orders.mdb")
Set rsOrders = dbOrders.OpenRecordset("SELECT * FROM Order_Item")
With rsOrders
.AddNew
![Order#] = Me.txtOrderNo
!Catalogue_Code = Me.txtCode
!Item_Description = Me.txtDescription
!Unit_Cost = Me.txtCost
!Quantity = Me.txtQuantity
!Total_Cost = total
.Update
End With
rsOrders.Close
dbOrders.Close
Form_Order_Form.Requery
DoCmd.Close
Form_Order_Form.Requery
End Sub
I added the requery twice just to see if it made a difference requerying after the form is closed.
Thanks for any help.
The code in the Add Item button is -
Private Sub cmdAdd_Click()
Dim total As Currency
Dim dbOrders As Database
Dim rsOrders As DAO.Recordset
total = Me.txtCost * Me.txtQuantity
Set dbOrders = OpenDatabase(Application.CurrentProject.Path & "\Orders.mdb")
Set rsOrders = dbOrders.OpenRecordset("SELECT * FROM Order_Item")
With rsOrders
.AddNew
![Order#] = Me.txtOrderNo
!Catalogue_Code = Me.txtCode
!Item_Description = Me.txtDescription
!Unit_Cost = Me.txtCost
!Quantity = Me.txtQuantity
!Total_Cost = total
.Update
End With
rsOrders.Close
dbOrders.Close
Form_Order_Form.Requery
DoCmd.Close
Form_Order_Form.Requery
End Sub
I added the requery twice just to see if it made a difference requerying after the form is closed.
Thanks for any help.