473,395 Members | 1,574 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

refresh list after totaling items

17
Hi,
I have a combo box that is set up to receive items from another from and post as a record set. The items will post to the list as I click an add item button. I also have a remove item button. I also have a total button at the bottom of my screen that when clicked will total the items in the list. What I want to be able to do is retotal the items in the list after removing an item. Right now if I remove items from my list it will not be shown in the list but it continues to count them and give me a wrong total. I also have another problem with the remove item button. The button will remove the first item in the list as it is clicked instead of removing the latest entry. I have attached the code for all the buttons below. Thanks for your help.

Private Sub cmdAdd_Click()
If Nz(TextQuantity.Value, "") = "" Then TextQuantity.Value = "1"
If Nz(cmbItem.Value, "") <> "" Then
Dim rs As DAO.Recordset
Set rs = DBEngine(0)(0).OpenRecordset("SELECT Cost FROM [Medical Supplies] WHERE Item = '" & removeApostrophes(cmbItem.Value) & "';")
If Not rs.EOF Then total = total + (CSng(rs!Cost) * CInt(TextQuantity.Value))
lstOrder.AddItem (TextQuantity.Value & "x " & cmbItem.Value)
End If

End Sub


Private Sub cmdTotal_Click()
TextTotal.Value = Round(total, 2)

End Sub

Private Sub Command42_Click()
'This for my reset total button'
TextTotal.Value = DefaultValue
End Sub

Private Sub Form_Load()
Dim i As Integer
For i = 0 To lstOrder.ListCount - 1
lstOrder.RemoveItem (0)
Next i
total = 0
End Sub

Option Compare Database

Dim total As Single

Private Sub cmdremove_Click()
lstOrder.RemoveItem Index:=varItem

On Error GoTo 0

End Sub
Nov 20 '07 #1
1 1687
puppydogbuddy
1,923 Expert 1GB
You have a posted similar question at the following link:

http://www.thescripts.com/forum/thread740618.html
Nov 24 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: Doug | last post by:
Hi I have a combo box (A) that populates a following combo box (B) based on a selection. The selection from the first combo box (A) initiates an OleDbDataAdapter routine that extracts the...
3
by: david | last post by:
I do not have the experience with it. For example, update the data in the ASP form every minute by retrieving data from database. Or do you have other methods? Thank you for any advice and...
8
by: Radx | last post by:
Here in my web application, I have a data entry page with serval controls. Some of the controls have autopostback is set true. But the problem is when two or more people are entering data at the...
3
by: plgii | last post by:
I have modal pop-up form1 showing list of items. There is a button that opens a new modal pop-up form2 which is a tabbed form (not subform) to add items to form1, form1 is still open behind form2....
4
by: NormAmst | last post by:
I have a list of CPU processing times and job durations for an entire department at work. There are 3 classifications I am maintaining. CPU time during peak hours , CPU time during non peak hours...
5
by: Randy | last post by:
I have button that deletes items from a SQL datatable. The items are displayed for the user in listbox, which is bound to the dataset. The code works just fine insofar as it deletes the correct...
0
by: achio84 | last post by:
Hi all, I'm a newbie in .Net programming. I'm developing a web application that has a listbox containing more than 1000++ items. This listbox is dynamic as the content will change on a time...
6
convexcube
by: convexcube | last post by:
After searching the web for a solution to total a specific column in a list box and not finding it, I came up with this: Dim varTotal As Currency Dim varRow As Integer For varRow = 1 To...
5
by: BlackBox | last post by:
I have a Listbox1 in the main form and I can add listbox1 items in the parent form. But when I close the parent form Listbox1 in the main form does not get refresh. I need to re-open the app. ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.