i have problem with the listbox (1 Viewer)

Dlovan-IT

Registered User.
Local time
Today, 16:28
Joined
Oct 9, 2013
Messages
84
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
 

Attachments

  • Capture.JPG
    Capture.JPG
    35.5 KB · Views: 87

spikepl

Eledittingent Beliped
Local time
Today, 15:28
Joined
Nov 3, 2010
Messages
6,142
I do not understand what you want. Use SHORT complete sentences. Ask a friend to read the text and keep changing it until he understands it. And then repost :D
 

Dlovan-IT

Registered User.
Local time
Today, 16:28
Joined
Oct 9, 2013
Messages
84
I do not understand what you want. Use SHORT complete sentences. Ask a friend to read the text and keep changing it until he understands it. And then repost :D

brother i create a form using for sell item , the form was contain list and one textbox the textbox used for writing the barcode my problem here when i wrote the barcode the first item add to the list but not shown in the list , but when i wrote another barcode and added the list display i don't no what is problem the above code is the code used for the add item to the list
 

spikepl

Eledittingent Beliped
Local time
Today, 15:28
Joined
Nov 3, 2010
Messages
6,142
The purpose of sentences is to express some contiguous thought and make a text readable.
A sentence is a bit of text that in English begins with a capital (Large letter) and ends with a "." Try to break your text down into simple small sentences. Then get a new friend to try to understand and check your text. And repost it here.

Or write a story like this:


  1. I input X into field Y
  2. The system does (words to say what the system does) and that is fine (or not, as the case may be)
  3. I then press this button
  4. The system show the message M that I want
  5. I then type Z in field A and press B
  6. The system shows C but I wanted D
 

Dlovan-IT

Registered User.
Local time
Today, 16:28
Joined
Oct 9, 2013
Messages
84
ok here is my story

1- I input the barcode in the Textbox lets say our barcode is "00001"

2- after that press Enter

3- the item is added to the listbox that i want

4- the item was not show in the listbox but i have a textbox to get the Total of the Price one of the column listbox is Price the price show in the Textbox

5- I input another barcode lets say 00002

6- press Enter and the item was added to the listbox also show to the listbox

my problem here just the first was not show simultaneous added to the listbox
 

Dlovan-IT

Registered User.
Local time
Today, 16:28
Joined
Oct 9, 2013
Messages
84
As odrozd has suggested you need to requery. Your current requery will not fire unless you have an error.
Code:
 z:
MsgBox "so sorry"
 Me.Requery

i have not error brother i know the requery is false but i don't no where i put it
 

odrozd

New member
Local time
Today, 06:28
Joined
Mar 24, 2012
Messages
9
i have not error brother i know the requery is false but i don't no where i put it

On the box that asks for the data
Go to properties.

Go to after update.
Create macro to requery

Hope it helps
 

POM

Registered User.
Local time
Today, 16:28
Joined
Dec 27, 2013
Messages
39
OR try this maybe work
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
me.refersh

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
 

Users who are viewing this thread

Top Bottom