473,398 Members | 2,120 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,398 software developers and data experts.

Listbox based on text box and combo box.


On an unbound form, I have a combobox called 'cboproducttype' and a
text box called 'txtamountappliedfor'.

I have an Add button that I would like the user to be able to hit once
a product and amount applied for has been entered. This should
populate an unbound listbox to display their selections. A user can
select one or more sets of product types and the amount applied for.
They should also have the functionality to remove a 'set' if they made
a mistake without the need to rebuild the whole listbox of
selections.

Then - I want to loop through the listbox of selections to see what is
being requested. (I know how to do this part - just wanted to let you
all know why I am doing this)

My question - to populate the listbox - I was starting with just
updating the recordsource and having the recordsource type set to
'value list'. However this seems to cause a few issues. For
instance, I couldn't display the amount as applied for as currency.

Am I going down the wrong road? Should I consider a querydef? Or
should the way I was thinking work?

Thanks,
-Brian

Aug 1 '07 #1
6 3353
On Tue, 31 Jul 2007 18:40:16 -0700, BerkshireGuy
<be*************************@yahoo.comwrote:

The listbox displays text. You can format a value as currency before
adding to the listbox:
MyListbox.RowSource = Format$(txtAmountAppliedFor, "Currency") 'etc.
>
On an unbound form, I have a combobox called 'cboproducttype' and a
text box called 'txtamountappliedfor'.

I have an Add button that I would like the user to be able to hit once
a product and amount applied for has been entered. This should
populate an unbound listbox to display their selections. A user can
select one or more sets of product types and the amount applied for.
They should also have the functionality to remove a 'set' if they made
a mistake without the need to rebuild the whole listbox of
selections.

Then - I want to loop through the listbox of selections to see what is
being requested. (I know how to do this part - just wanted to let you
all know why I am doing this)

My question - to populate the listbox - I was starting with just
updating the recordsource and having the recordsource type set to
'value list'. However this seems to cause a few issues. For
instance, I couldn't display the amount as applied for as currency.

Am I going down the wrong road? Should I consider a querydef? Or
should the way I was thinking work?

Thanks,
-Brian
Aug 1 '07 #2
On Jul 31, 10:25 pm, Tom van Stiphout <no.spam.tom7...@cox.netwrote:
On Tue, 31 Jul 2007 18:40:16 -0700, BerkshireGuy

<berkshireguy2005-commeri...@yahoo.comwrote:

The listbox displays text. You can format a value as currency before
adding to the listbox:
MyListbox.RowSource = Format$(txtAmountAppliedFor, "Currency") 'etc.


On an unbound form, I have a combobox called 'cboproducttype' and a
text box called 'txtamountappliedfor'.
I have an Add button that I would like the user to be able to hit once
a product and amount applied for has been entered. This should
populate an unbound listbox to display their selections. A user can
select one or more sets of product types and the amount applied for.
They should also have the functionality to remove a 'set' if they made
a mistake without the need to rebuild the whole listbox of
selections.
Then - I want to loop through the listbox of selections to see what is
being requested. (I know how to do this part - just wanted to let you
all know why I am doing this)
Tom:

I tried that earlier and it's causing a problem because of the "," in
the currency amount. It seperates everything after the common and
thinks it's another valuie, thus moving the 0's to the it's own
column.

Here is the code:

Private Sub cmdAdd_Click()

If Len(Me.lstbxSelectedProductTypes.RowSource) = 0 Then
Me.lstbxSelectedProductTypes.RowSource =
Me.cboProductType.Column(0) & ";" & Format$(Me.txtAmountAppliedFor,
"Currency") & ";"
Else
Me.lstbxSelectedProductTypes.RowSource =
Me.lstbxSelectedProductTypes.RowSource & _
Me.cboProductType.Column(0) & ";" & Format$
(Me.txtAmountAppliedFor, "Currency") & ";"
End If
End Sub

Thanks
B

>
My question - to populate the listbox - I was starting with just
updating the recordsource and having the recordsource type set to
'value list'. However this seems to cause a few issues. For
instance, I couldn't display the amount as applied for as currency.
Am I going down the wrong road? Should I consider a querydef? Or
should the way I was thinking work?
Thanks,
-Brian- Hide quoted text -

- Show quoted text -

Aug 1 '07 #3
On Tue, 31 Jul 2007 19:48:33 -0700, BerkshireGuy
<be*************************@yahoo.comwrote:

Fortunately there is a simple solution: wrap the currency values in
double-quotes.

-Tom.

>On Jul 31, 10:25 pm, Tom van Stiphout <no.spam.tom7...@cox.netwrote:
>On Tue, 31 Jul 2007 18:40:16 -0700, BerkshireGuy

<berkshireguy2005-commeri...@yahoo.comwrote:

The listbox displays text. You can format a value as currency before
adding to the listbox:
MyListbox.RowSource = Format$(txtAmountAppliedFor, "Currency") 'etc.


>On an unbound form, I have a combobox called 'cboproducttype' and a
text box called 'txtamountappliedfor'.
>I have an Add button that I would like the user to be able to hit once
a product and amount applied for has been entered. This should
populate an unbound listbox to display their selections. A user can
select one or more sets of product types and the amount applied for.
They should also have the functionality to remove a 'set' if they made
a mistake without the need to rebuild the whole listbox of
selections.
>Then - I want to loop through the listbox of selections to see what is
being requested. (I know how to do this part - just wanted to let you
all know why I am doing this)

Tom:

I tried that earlier and it's causing a problem because of the "," in
the currency amount. It seperates everything after the common and
thinks it's another valuie, thus moving the 0's to the it's own
column.

Here is the code:

Private Sub cmdAdd_Click()

If Len(Me.lstbxSelectedProductTypes.RowSource) = 0 Then
Me.lstbxSelectedProductTypes.RowSource =
Me.cboProductType.Column(0) & ";" & Format$(Me.txtAmountAppliedFor,
"Currency") & ";"
Else
Me.lstbxSelectedProductTypes.RowSource =
Me.lstbxSelectedProductTypes.RowSource & _
Me.cboProductType.Column(0) & ";" & Format$
(Me.txtAmountAppliedFor, "Currency") & ";"
End If
End Sub

Thanks
B

>>
>My question - to populate the listbox - I was starting with just
updating the recordsource and having the recordsource type set to
'value list'. However this seems to cause a few issues. For
instance, I couldn't display the amount as applied for as currency.
>Am I going down the wrong road? Should I consider a querydef? Or
should the way I was thinking work?
>Thanks,
-Brian- Hide quoted text -

- Show quoted text -
Aug 1 '07 #4
Ok - but will that maintain the value as currency when I read the
values back?

-B
On Jul 31, 11:14 pm, Tom van Stiphout <no.spam.tom7...@cox.netwrote:
On Tue, 31 Jul 2007 19:48:33 -0700, BerkshireGuy

<berkshireguy2005-commeri...@yahoo.comwrote:

Fortunately there is a simple solution: wrap the currency values in
double-quotes.

-Tom.
On Jul 31, 10:25 pm, Tom van Stiphout <no.spam.tom7...@cox.netwrote:
On Tue, 31 Jul 2007 18:40:16 -0700, BerkshireGuy
<berkshireguy2005-commeri...@yahoo.comwrote:
The listbox displays text. You can format a value as currency before
adding to the listbox:
MyListbox.RowSource = Format$(txtAmountAppliedFor, "Currency") 'etc.
On an unbound form, I have a combobox called 'cboproducttype' and a
text box called 'txtamountappliedfor'.
I have an Add button that I would like the user to be able to hit once
a product and amount applied for has been entered. This should
populate an unbound listbox to display their selections. A user can
select one or more sets of product types and the amount applied for.
They should also have the functionality to remove a 'set' if they made
a mistake without the need to rebuild the whole listbox of
selections.
Then - I want to loop through the listbox of selections to see what is
being requested. (I know how to do this part - just wanted to let you
all know why I am doing this)
Tom:
I tried that earlier and it's causing a problem because of the "," in
the currency amount. It seperates everything after the common and
thinks it's another valuie, thus moving the 0's to the it's own
column.
Here is the code:
Private Sub cmdAdd_Click()
If Len(Me.lstbxSelectedProductTypes.RowSource) = 0 Then
Me.lstbxSelectedProductTypes.RowSource =
Me.cboProductType.Column(0) & ";" & Format$(Me.txtAmountAppliedFor,
"Currency") & ";"
Else
Me.lstbxSelectedProductTypes.RowSource =
Me.lstbxSelectedProductTypes.RowSource & _
Me.cboProductType.Column(0) & ";" & Format$
(Me.txtAmountAppliedFor, "Currency") & ";"
End If
End Sub
Thanks
B
My question - to populate the listbox - I was starting with just
updating the recordsource and having the recordsource type set to
'value list'. However this seems to cause a few issues. For
instance, I couldn't display the amount as applied for as currency.
Am I going down the wrong road? Should I consider a querydef? Or
should the way I was thinking work?
Thanks,
-Brian- Hide quoted text -
- Show quoted text -- Hide quoted text -

- Show quoted text -

Aug 1 '07 #5
On Tue, 31 Jul 2007 20:54:46 -0700, BerkshireGuy
<be*************************@yahoo.comwrote:

Please post back after you have taken 10 seconds to try that.
-Tom.

>Ok - but will that maintain the value as currency when I read the
values back?

-B
On Jul 31, 11:14 pm, Tom van Stiphout <no.spam.tom7...@cox.netwrote:
>On Tue, 31 Jul 2007 19:48:33 -0700, BerkshireGuy

<berkshireguy2005-commeri...@yahoo.comwrote:

Fortunately there is a simple solution: wrap the currency values in
double-quotes.

-Tom.
>On Jul 31, 10:25 pm, Tom van Stiphout <no.spam.tom7...@cox.netwrote:
On Tue, 31 Jul 2007 18:40:16 -0700, BerkshireGuy
><berkshireguy2005-commeri...@yahoo.comwrote:
>The listbox displays text. You can format a value as currency before
adding to the listbox:
MyListbox.RowSource = Format$(txtAmountAppliedFor, "Currency") 'etc.
>On an unbound form, I have a combobox called 'cboproducttype' and a
text box called 'txtamountappliedfor'.
>I have an Add button that I would like the user to be able to hit once
a product and amount applied for has been entered. This should
populate an unbound listbox to display their selections. A user can
select one or more sets of product types and the amount applied for.
They should also have the functionality to remove a 'set' if they made
a mistake without the need to rebuild the whole listbox of
selections.
>Then - I want to loop through the listbox of selections to see what is
being requested. (I know how to do this part - just wanted to let you
all know why I am doing this)
>Tom:
>I tried that earlier and it's causing a problem because of the "," in
the currency amount. It seperates everything after the common and
thinks it's another valuie, thus moving the 0's to the it's own
column.
>Here is the code:
>Private Sub cmdAdd_Click()
>If Len(Me.lstbxSelectedProductTypes.RowSource) = 0 Then
Me.lstbxSelectedProductTypes.RowSource =
Me.cboProductType.Column(0) & ";" & Format$(Me.txtAmountAppliedFor,
"Currency") & ";"
Else
Me.lstbxSelectedProductTypes.RowSource =
Me.lstbxSelectedProductTypes.RowSource & _
Me.cboProductType.Column(0) & ";" & Format$
(Me.txtAmountAppliedFor, "Currency") & ";"
End If
End Sub
>Thanks
B
>My question - to populate the listbox - I was starting with just
updating the recordsource and having the recordsource type set to
'value list'. However this seems to cause a few issues. For
instance, I couldn't display the amount as applied for as currency.
>Am I going down the wrong road? Should I consider a querydef? Or
should the way I was thinking work?
>Thanks,
-Brian- Hide quoted text -
>- Show quoted text -- Hide quoted text -

- Show quoted text -
Aug 1 '07 #6
This worked - thanks Tom.

Here is the code if anyone needs it:

Adding to the unbound listbox:

If Len(Me.lstbxSelectedProductTypes.RowSource) = 0 Then
Me.lstbxSelectedProductTypes.RowSource =
Me.cboProductType.Column(0) & ";'" & _
Format$(Me.txtAmountAppliedFor, "Currency") & "';"
Else
Me.lstbxSelectedProductTypes.RowSource =
Me.lstbxSelectedProductTypes.RowSource & _
Me.cboProductType.Column(0) & ";'" & Format$
(Me.txtAmountAppliedFor, "Currency") & "';"
End If

Read the values from the listbiox. Note that I had to force select
all before stepping through the listbox. This necessary?

Dim ctl As Control
Dim varItem As Variant, i As Integer

Set ctl = Me.lstbxSelectedProductTypes

For i = 0 To ctl.ListCount
ctl.Selected(i) = True
Next

For Each varItem In ctl.ItemsSelected
Debug.Print ctl.Column(0, varItem) & " " & CCur(ctl.Column(1,
varItem))

Next varItem





On Aug 1, 12:44 am, Tom van Stiphout <no.spam.tom7...@cox.netwrote:
On Tue, 31 Jul 2007 20:54:46 -0700, BerkshireGuy

<berkshireguy2005-commeri...@yahoo.comwrote:

Please post back after you have taken 10 seconds to try that.
-Tom.
Ok - but will that maintain the value as currency when I read the
values back?
-B
On Jul 31, 11:14 pm, Tom van Stiphout <no.spam.tom7...@cox.netwrote:
On Tue, 31 Jul 2007 19:48:33 -0700, BerkshireGuy
<berkshireguy2005-commeri...@yahoo.comwrote:
Fortunately there is a simple solution: wrap the currency values in
double-quotes.
-Tom.
On Jul 31, 10:25 pm, Tom van Stiphout <no.spam.tom7...@cox.netwrote:
On Tue, 31 Jul 2007 18:40:16 -0700, BerkshireGuy
<berkshireguy2005-commeri...@yahoo.comwrote:
The listbox displays text. You can format a value as currency before
adding to the listbox:
MyListbox.RowSource = Format$(txtAmountAppliedFor, "Currency") 'etc.
On an unbound form, I have a combobox called 'cboproducttype' and a
text box called 'txtamountappliedfor'.
I have an Add button that I would like the user to be able to hit once
a product and amount applied for has been entered. This should
populate an unbound listbox to display their selections. A user can
select one or more sets of product types and the amount applied for.
They should also have the functionality to remove a 'set' if they made
a mistake without the need to rebuild the whole listbox of
selections.
Then - I want to loop through the listbox of selections to see what is
being requested. (I know how to do this part - just wanted to let you
all know why I am doing this)
Tom:
I tried that earlier and it's causing a problem because of the "," in
the currency amount. It seperates everything after the common and
thinks it's another valuie, thus moving the 0's to the it's own
column.
Here is the code:
Private Sub cmdAdd_Click()
If Len(Me.lstbxSelectedProductTypes.RowSource) = 0 Then
Me.lstbxSelectedProductTypes.RowSource =
Me.cboProductType.Column(0) & ";" & Format$(Me.txtAmountAppliedFor,
"Currency") & ";"
Else
Me.lstbxSelectedProductTypes.RowSource =
Me.lstbxSelectedProductTypes.RowSource & _
Me.cboProductType.Column(0) & ";" & Format$
(Me.txtAmountAppliedFor, "Currency") & ";"
End If
End Sub
Thanks
B
My question - to populate the listbox - I was starting with just
updating the recordsource and having the recordsource type set to
'value list'. However this seems to cause a few issues. For
instance, I couldn't display the amount as applied for as currency.
Am I going down the wrong road? Should I consider a querydef? Or
should the way I was thinking work?
Thanks,
-Brian- Hide quoted text -
- Show quoted text -- Hide quoted text -
- Show quoted text -- Hide quoted text -

- Show quoted text -

Aug 1 '07 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: RRT | last post by:
I have an existing table which describes Streets and sections of streets between intersections: Table 1: Streets by Intersections Street Area Ann St. Main to Jackson...
7
by: Colleyville Alan | last post by:
I have an app in which users are displayed a list of mutual fund from which they can choose. There is a listbox embedded in a two-tabbed notebook control. When the form is initally opened, the...
9
by: Megan | last post by:
Hi- I'm creating a database of music bands with their cds and songs. I'm trying to program an SQL statement so that I can enter a string of text in a textbox, press the 'Enter' key, and have...
1
by: andrew.panin | last post by:
Hi there! I've got a trouble with these things. What's going on? 1ST STEP: we have ListBox item. Let's call it ListBox1. We're adding four values to it using AddItem method:...
4
by: fat | last post by:
I have a drop down combo box that displays a list of customers , and the list is growing.. I would like to click the dropdown arrow and have a List box in a new form open, then i can choose a...
7
by: technocraze | last post by:
Hi guys, I encountered this error while using the AfterUpdate event for my listbox. Error: Update or CancelUpdate without using AddNew or Edit. What i wanted to achieve is just to display the...
3
by: deejayquai | last post by:
Hello Simple one this I guess, but I'm quite stuck at the moment. I would like to update the records displayed in my listbox (lstStudents) using criteria selected from my combo (cboForm) in a...
20
by: exipnakias | last post by:
Hello Guys. In a form I created a listbox which looks up the values of a table. I want: 1) ..to create a query where a parameter will be needed in order to be loaded. But I do not want to...
1
by: troy_lee | last post by:
I have a list box based on a query. I set the row source in vba with a dynamic string. I have a combo box at the top of the form that selects a unit number (formatted as text). This unit number...
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: 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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.