Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Textbox value needs to be dependant on List box values

Status
Not open for further replies.

Danyul

Technical User
Jul 5, 2001
36
AU
Hi,

I'm sure this should be easy, but I can't solve it at the moment!

I have two list boxes on a form which each hold a count of the no. of entries in a table in the database.

I need a text box (or some other control?) to show the difference between the 2 listbox values.

e.g.> TextBox1.value = ListBox1.value - ListBox2.value

How do i do this?

Regards

Dan
 
I'm not sure what you mean by the listbox holds a count of the entries. Why are you using a listbox. If all you want is the total records in a table you can do this with textboxs using the DCount funtion.

TextBox1: ControlSource value would be...
=DCount("*","Table1")
TextBox2: ControlSource value would be...
=DCount("*","Table2")
TextBox3: ControlSource value would be...
=[TextBox1]-[TextBox2]

If there is a particular reason you have to use a listbox, then we will need more information.

B-) ljprodev@yahoo.com
ProDev
MS Access Applications
 
Thank you both,

The DCount method works fine. The reason I was using list boxes was to allow me to use a query to define their contents. (In case I need them to contain a count of a subset of the information etc.).

On exploring the DCount function I find I can include some query criteria that may negate the need for using listboxes.

HOWEVER (!) If I do need to continue using listboxes (for elegance of the solution etc.) I couldn't make Cosmo's solution work, =[ListBox1]-[ListBox2] ,do I need to specify an entry in the listbox (even though it currently only hold one value) ? If so how do I do this?
e.g.
=[ListBox1].entry(x).value - [ListBox2].entry(x).value

Regards

Dan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top