Ask a Question related to Microsoft Access, Design and Development.
-
Alastair MacFarlane #1
ListBox Question
Dear All,
Can you programatically select an item in a ListBox based
on the value entered in a text box from the after_update
event? I have tried the following code which does not work:
forms!Form1!MyListBox.SelectedItem = me!Text1.text, or
forms!Form1!MyListBox.value.column(1) = me!Text1.text
The bound column of the ListBox is Column(0). I want the
TextBox to be used to select the Column(1) value.
Thanks for all help...
Alastair MacFarlane
Alastair MacFarlane Guest
-
listbox to populate a listbox
I am trying to use a listbox that I have setup using flash remoting call to a db. What I want to happen is when you click on a item in first the... -
click listbox and refresh another listbox
Can someone guide me to a resource on building set of drill-down listboxes? Basically I want to have 4 listboxes. The first starts out with... -
Item label displays as "," when moving from listbox to listbox
I have 2 listboxes: "lb_unselected" and "lb_selected". The first thing in the actions is loop through an array populating these two listboxes. ... -
now desparate! - 1st listbox contents disappears when 2nd listbox appears?
On 23 Jun 2003 12:57:45 -0700, KathyBurke40@attbi.com (KathyB) wrote: Its been a while since you posted but I will answer anyway. The problem... -
Easy listbox question
Hi, I have a listbox with 3 columns, and I have an event for doubleclick on the listbox, but I do not know the syntax for putting the... -
Michel Walsh #2
Re: ListBox Question
Hi,
The assignment operator assign what is to the right to what is to the left. The syntax should have
been
Me.Text1.Value= Forms!Form1!MyComboBox.value.column(1)
Also note that in Access, the value is held into the property VALUE, not the property TEXT. A
Value is of data type VARIANT, so it can handle the values NULL without problem. A Text data type
is a STRING and cannot handle a Variant, so, it cannot handle a NULL, which is a frequent value in
databases (outer join, or otherwise). Also, in Access, the Text property is only valid when the
control has the focus, it then hold the data like it is actually typed by the end user, while Value
is the last validated (by the control) value (not necessary saved in the table), and OldValue the
last committed value (in the record, validatated in the table).
If the list box has the possibility to let the user select more than one value (multiselect), you
have to use the ItemData property of the Listbox, after you " point" to the selected row of your
liking (see [url]http://www.mvps.org/access/forms/frm0007.htm[/url], or the help file for more examples on how
to access these data).
Hoping it may help,
Vanderghast, Access MVP
"Alastair MacFarlane" <amacfarlane@blueyonder.co.uk> wrote in message
news:0d0e01c3453e$db6823f0$a301280a@phx.gbl...> Dear All,
>
> Can you programatically select an item in a ListBox based
> on the value entered in a text box from the after_update
> event? I have tried the following code which does not work:
>
> forms!Form1!MyListBox.SelectedItem = me!Text1.text, or
> forms!Form1!MyListBox.value.column(1) = me!Text1.text
>
> The bound column of the ListBox is Column(0). I want the
> TextBox to be used to select the Column(1) value.
>
> Thanks for all help...
>
> Alastair MacFarlane
>
>
>
>
>
Michel Walsh Guest
-
Alastair MacFarlane #3
Re: ListBox Question
Vanderghast,
Thanks for the reply! I am sorry if I am confusing the
issue. What I would like is to enter text in a text box
and the value in the Value property of the TextBox would
highlight itself in column(1) of a ListBox? and not the
other way round. To obtain the value from a selected
ListBox to the TextBox would be straightforward. The
converse does not work.
Forms!Form1!MyComboBox.value.column(1)=Me.Text1.Va lue
Any suggestions?
Thanks again...
Alastair MacFarlane
what is to the left. The syntax should have>-----Original Message-----
>Hi,
>
>
>The assignment operator assign what is to the right toproperty VALUE, not the property TEXT. A>been
>
>
> Me.Text1.Value= Forms!Form1!MyComboBox.value.column(1)
>
>
>Also note that in Access, the value is held into thevalues NULL without problem. A Text data type>Value is of data type VARIANT, so it can handle thehandle a NULL, which is a frequent value in>is a STRING and cannot handle a Variant, so, it cannotthe Text property is only valid when the>databases (outer join, or otherwise). Also, in Access,actually typed by the end user, while Value>control has the focus, it then hold the data like it isnecessary saved in the table), and OldValue the>is the last validated (by the control) value (nottable).>last committed value (in the record, validatated in theselect more than one value (multiselect), you>
>
>If the list box has the possibility to let the useryou " point" to the selected row of your>have to use the ItemData property of the Listbox, afteror the help file for more examples on how>liking (see [url]http://www.mvps.org/access/forms/frm0007.htm[/url],wrote in message>to access these data).
>
>
>Hoping it may help,
>Vanderghast, Access MVP
>
>
>"Alastair MacFarlane" <amacfarlane@blueyonder.co.uk>based>news:0d0e01c3453e$db6823f0$a301280a@phx.gbl...>> Dear All,
>>
>> Can you programatically select an item in a ListBoxwork:>> on the value entered in a text box from the after_update
>> event? I have tried the following code which does not>>>
>> forms!Form1!MyListBox.SelectedItem = me!Text1.text, or
>> forms!Form1!MyListBox.value.column(1) = me!Text1.text
>>
>> The bound column of the ListBox is Column(0). I want the
>> TextBox to be used to select the Column(1) value.
>>
>> Thanks for all help...
>>
>> Alastair MacFarlane
>>
>>
>>
>>
>>
>
>.
>Alastair MacFarlane Guest
-
Alastair MacFarlane #4
Re: ListBox Question
Vanderghast,
Thanks for the reply! I am sorry if I am confusing the
issue. What I would like is to enter text in a text box
and the value in the Value property of the TextBox would
highlight itself in column(1) of a ListBox? and not the
other way round. To obtain the value from a selected
ListBox to the TextBox would be straightforward. The
converse does not work.
Forms!Form1!MyComboBox.value.column(1)=Me.Text1.Va lue
Any suggestions?
Thanks again...
Alastair MacFarlane
what is to the left. The syntax should have>-----Original Message-----
>Hi,
>
>
>The assignment operator assign what is to the right toproperty VALUE, not the property TEXT. A>been
>
>
> Me.Text1.Value= Forms!Form1!MyComboBox.value.column(1)
>
>
>Also note that in Access, the value is held into thevalues NULL without problem. A Text data type>Value is of data type VARIANT, so it can handle thehandle a NULL, which is a frequent value in>is a STRING and cannot handle a Variant, so, it cannotthe Text property is only valid when the>databases (outer join, or otherwise). Also, in Access,actually typed by the end user, while Value>control has the focus, it then hold the data like it isnecessary saved in the table), and OldValue the>is the last validated (by the control) value (nottable).>last committed value (in the record, validatated in theselect more than one value (multiselect), you>
>
>If the list box has the possibility to let the useryou " point" to the selected row of your>have to use the ItemData property of the Listbox, afteror the help file for more examples on how>liking (see [url]http://www.mvps.org/access/forms/frm0007.htm[/url],wrote in message>to access these data).
>
>
>Hoping it may help,
>Vanderghast, Access MVP
>
>
>"Alastair MacFarlane" <amacfarlane@blueyonder.co.uk>based>news:0d0e01c3453e$db6823f0$a301280a@phx.gbl...>> Dear All,
>>
>> Can you programatically select an item in a ListBoxwork:>> on the value entered in a text box from the after_update
>> event? I have tried the following code which does not>>>
>> forms!Form1!MyListBox.SelectedItem = me!Text1.text, or
>> forms!Form1!MyListBox.value.column(1) = me!Text1.text
>>
>> The bound column of the ListBox is Column(0). I want the
>> TextBox to be used to select the Column(1) value.
>>
>> Thanks for all help...
>>
>> Alastair MacFarlane
>>
>>
>>
>>
>>
>
>.
>Alastair MacFarlane Guest
-
Dan Artuso #5
Re: ListBox Question
Hi,
Not sure if this is the best way, but it will work:
Dim i As Integer
For i = 0 To Me.List0.ListCount - 1
If Me.List0.Column(1, i) = Me.Text3 Then
Me.List0.Selected(i) = True
End If
Next
--
HTH
Dan Artuso, Access MVP
"Alastair MacFarlane" <amacfarlane@blueyonder.co.uk> wrote in message
news:0d0e01c3453e$db6823f0$a301280a@phx.gbl...> Dear All,
>
> Can you programatically select an item in a ListBox based
> on the value entered in a text box from the after_update
> event? I have tried the following code which does not work:
>
> forms!Form1!MyListBox.SelectedItem = me!Text1.text, or
> forms!Form1!MyListBox.value.column(1) = me!Text1.text
>
> The bound column of the ListBox is Column(0). I want the
> TextBox to be used to select the Column(1) value.
>
> Thanks for all help...
>
> Alastair MacFarlane
>
>
>
>
>
Dan Artuso Guest
-
Mike P #6
listbox question
I have the following code in my Page_Load event to populate a listbox
from a database :
if (!(Page.IsPostBack))
{
SqlConnection objConnection = new
SqlConnection(ConfigurationSettings.AppSettings["strConnectTransitTest"]
);
string strTelcoNumber = "SELECT DISTINCT OSValue FROM CallTypeSwitch
ORDER BY OSValue";
//You must open the connection before populating the DataReader
objConnection.Open();
SqlCommand objCmd = new SqlCommand(strTelcoNumber, objConnection);
//Create/Populate the DataReader
SqlDataReader objDataReader = null;
objDataReader = objCmd.ExecuteReader();
//Databind the DataReader to the listbox Web control
lstRoutes.DataSource = objDataReader;
lstRoutes.DataBind();
}
What I want to do is to get rid of the IsPostback so that if the
database is updated the listbox will also be updated. But in order to
do this I need to store the value chosen by the user and set the listbox
to that value on my Submit button click event. I think ViewState might
be the right way to go about this but I have no real experience of using
this in C#. Does any body know how to do this?
Any advice would be much appreciated.
Cheers,
Mike
*** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
Don't just participate in USENET...get rewarded for it!
Mike P Guest
-
S. Justin Gengo #7
Re: listbox question
Mike, you'll be happt to hear that it's pretty darn easy.
From the code behind page ViewState functions very similarly to a Session or
Application variable (as far as setting and retrieving it).
Now, I program mostly in VB.Net, but the syntax shouldn't be too different.
Just look at how you set a Session or Application level variable in c# and
ViewState will be about the same.
In VB you set it like this:
ViewState("[Your Key Name Here]") = [Your Object Here]
Or
ViewState.Add("[Your Key Name Here]", [Your Object Here])
Now, I question for your purposes here if you even need to use viewstate.
If all you're worried about is resetting the list box to the item a user
chose then wouldn't you get the item chosen, recreate the list box, and then
reselect the item?
This would all happen server side in one single trip wouldn't it?
If there was a post back to the client in the middle then you'd need to
store the value in view state, but otherwise why not just store it in a
regular old variable?
Sincerely,
--
S. Justin Gengo, MCP
Web Developer
Free code library at:
[url]www.aboutfortunate.com[/url]
"Out of chaos comes order."
Nietzche
"Mike P" <mrp@telcoelectronics.co.uk> wrote in message
news:epobtWBXDHA.3248@tk2msftngp13.phx.gbl...> I have the following code in my Page_Load event to populate a listbox
> from a database :
>
> if (!(Page.IsPostBack))
> {
> SqlConnection objConnection = new
> SqlConnection(ConfigurationSettings.AppSettings["strConnectTransitTest"]
> );
> string strTelcoNumber = "SELECT DISTINCT OSValue FROM CallTypeSwitch
> ORDER BY OSValue";
>
> //You must open the connection before populating the DataReader
> objConnection.Open();
>
> SqlCommand objCmd = new SqlCommand(strTelcoNumber, objConnection);
>
> //Create/Populate the DataReader
> SqlDataReader objDataReader = null;
> objDataReader = objCmd.ExecuteReader();
>
> //Databind the DataReader to the listbox Web control
> lstRoutes.DataSource = objDataReader;
> lstRoutes.DataBind();
> }
>
> What I want to do is to get rid of the IsPostback so that if the
> database is updated the listbox will also be updated. But in order to
> do this I need to store the value chosen by the user and set the listbox
> to that value on my Submit button click event. I think ViewState might
> be the right way to go about this but I have no real experience of using
> this in C#. Does any body know how to do this?
>
>
> Any advice would be much appreciated.
>
> Cheers,
>
> Mike
>
>
>
>
> *** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
> Don't just participate in USENET...get rewarded for it!
S. Justin Gengo Guest
-
Mike P #8
Re: listbox question
Justin,
In the Page_Load event can I set the value of the listbox to the value
entered by the user after I have re-populated it? And if so, what is
the syntax for doing this? Or do I have totally the wrong idea ?
(sorry, I am pretty new to ASP.NET and particularly what I am trying to
do now)
Mike
*** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
Don't just participate in USENET...get rewarded for it!
Mike P Guest
-
Mike P #9
Re: listbox question
Justin,
Thanks! I was struggling with it until I realised that I needed to take
my list populating code out of Page_Load and into it's own separate
function. Now it seems to work fine.
Cheers,
Mike
*** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
Don't just participate in USENET...get rewarded for it!
Mike P Guest



Reply With Quote

