i have the form contain 1 listbox and 2 textbox , one of the textbox is used for barcode another once is used for Quantity when write the barcode in the first textbox the item was added to the listbox but not shown the first record i need to close the form and opened after that shown this is my code also look the attachment to understand the design
Code:
On Error GoTo z
If ppp = 1 Then DoCmd.OpenQuery "tpd": ppp = 0
Dim db As Database
Dim db1 As Database
Dim rs As Recordset
Dim rs1 As Recordset
Set db = OpenDatabase("C:\DlovanDB\tbl_input.mdb")
Set db1 = OpenDatabase("C:\DlovanDB\tbl_temp.mdb")
Set rs = db.OpenRecordset("table2", dbOpenDynaset)
Set rs1 = db1.OpenRecordset("table3", dbOpenDynaset)
While rs.EOF = False
If rs!barcode = Val(Text1) And Val(Text14) <= rs!no Then
rs1.AddNew
rs1!Item = rs!Item
rs1!Date = rs!Date
rs1!pbuy = rs!pbuy
rs1!psell = rs!psell
rs1!barcode = Text1
rs1!no = Val(Text14)
rs1!dat = CStr(Date)
rs1.Update
rs.Edit
rs!no = rs!no - Val(Text14)
rs.Update
Else
End If
rs.Move 1
Wend
List11.RowSourceType = "table/query"
List11.RowSource = "SELECT table3.barcode as ÈÇÑßæÏ , table3.item as ßåÑÓÊå, table3.psell as äÑÎ, table3.[no] as ÏÇäå FROM table3"
rs1.MoveFirst
a = 0
While rs1.EOF = False
a = a + rs1!psell * rs1!no
rs1.Move 1
Wend
Text9 = a
Text1.SetFocus
Text14 = 1
Exit Sub
z:
MsgBox "so sorry"
Me.Requery