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

Populating a Listbox

Hi there,

I am currently running into a somewhat weired problem and hope that this NG
is able to help ;-)

I have a table in a MSSQL Server in which there is one Column that stores a
date. The Format is 04.03.2004

Now I want to populate a Listbox but only with the year from that Column. So
if I have lets say 10 entries with *.*.2004 and 5 with *.*.2003 I just want
to show 2003 and 2004 once in the Listbox.
Basically intended for a Searchform to search for entries from a specific
year.
I can get the Listbox to display the years allright but if I have 1000
entries in the Column I gett as much in the Listbox.
This is the Code I have so far

<select name="select">
<%
While (NOT rsMyDate.EOF)
%>
<option value="<% Response.Write (Month
(rsMyDate.Fields.Item("Date").Value)) %>"><% Response.Write (Month
(rsMyDate.Fields.Item("Date").Value)) %></option>
<%
rsMyDate.MoveNext()
Wend
If (rsMyDate.CursorType > 0) Then
rsMyDate.MoveFirst
Else
rsMyDate.Requery
End If
%>
</select>
Any ideas are greatly appreciated.

Cheers

Btw..sorry 4 crossposting ;-)
Jul 19 '05 #1
3 1931
Why is the date stored as a string and not a datetime value? If it was a
datetime value then you could use the intrinsic SQL functions to return the
relevant date part.

Chris.

"Broder" <br**********@gmx.net> wrote in message
news:c2*************@news.hansenet.net...
Hi there,

I am currently running into a somewhat weired problem and hope that this NG
is able to help ;-)

I have a table in a MSSQL Server in which there is one Column that stores a
date. The Format is 04.03.2004

Now I want to populate a Listbox but only with the year from that Column. So
if I have lets say 10 entries with *.*.2004 and 5 with *.*.2003 I just want
to show 2003 and 2004 once in the Listbox.
Basically intended for a Searchform to search for entries from a specific
year.
I can get the Listbox to display the years allright but if I have 1000
entries in the Column I gett as much in the Listbox.
This is the Code I have so far

<select name="select">
<%
While (NOT rsMyDate.EOF)
%>
<option value="<% Response.Write (Month
(rsMyDate.Fields.Item("Date").Value)) %>"><% Response.Write (Month
(rsMyDate.Fields.Item("Date").Value)) %></option>
<%
rsMyDate.MoveNext()
Wend
If (rsMyDate.CursorType > 0) Then
rsMyDate.MoveFirst
Else
rsMyDate.Requery
End If
%>
</select>
Any ideas are greatly appreciated.

Cheers

Btw..sorry 4 crossposting ;-)

Jul 19 '05 #2
Hi there,

excuse my ignorance but I have to confess I never heard of them ;-).
Actually in the DB it is stored in datetime

Broder

"Chris Barber" <ch***@blue-canoe.co.uk.NOSPAM> schrieb im Newsbeitrag
news:OY**************@TK2MSFTNGP09.phx.gbl...
Why is the date stored as a string and not a datetime value? If it was a
datetime value then you could use the intrinsic SQL functions to return the relevant date part.

Chris.

"Broder" <br**********@gmx.net> wrote in message
news:c2*************@news.hansenet.net...
Hi there,

I am currently running into a somewhat weired problem and hope that this NG is able to help ;-)

I have a table in a MSSQL Server in which there is one Column that stores a date. The Format is 04.03.2004

Now I want to populate a Listbox but only with the year from that Column. So if I have lets say 10 entries with *.*.2004 and 5 with *.*.2003 I just want to show 2003 and 2004 once in the Listbox.
Basically intended for a Searchform to search for entries from a specific
year.
I can get the Listbox to display the years allright but if I have 1000
entries in the Column I gett as much in the Listbox.
This is the Code I have so far

<select name="select">
<%
While (NOT rsMyDate.EOF)
%>
<option value="<% Response.Write (Month
(rsMyDate.Fields.Item("Date").Value)) %>"><% Response.Write (Month
(rsMyDate.Fields.Item("Date").Value)) %></option>
<%
rsMyDate.MoveNext()
Wend
If (rsMyDate.CursorType > 0) Then
rsMyDate.MoveFirst
Else
rsMyDate.Requery
End If
%>
</select>
Any ideas are greatly appreciated.

Cheers

Btw..sorry 4 crossposting ;-)

Jul 19 '05 #3
In which case use the DatePart function to output the specific part of the
datetime value that you want. It's also better when updating the database to
pass in an ISO datetime string in the SQL so that the database cannot
misinterpret your dates as either US or UK etc.

http://www.databasejournal.com/featu...le.php/2197931
http://www.databasejournal.com/featu...0894_2209321_2
http://www.techonthenet.com/access/f...e/datepart.htm
http://www.informit.com/articles/article.asp?p=31453

Chris.

"Broder" <br**********@gmx.net> wrote in message
news:c2*************@news.hansenet.net...
Hi there,

excuse my ignorance but I have to confess I never heard of them ;-).
Actually in the DB it is stored in datetime

Broder

"Chris Barber" <ch***@blue-canoe.co.uk.NOSPAM> schrieb im Newsbeitrag
news:OY**************@TK2MSFTNGP09.phx.gbl...
Why is the date stored as a string and not a datetime value? If it was a
datetime value then you could use the intrinsic SQL functions to return the relevant date part.

Chris.

"Broder" <br**********@gmx.net> wrote in message
news:c2*************@news.hansenet.net...
Hi there,

I am currently running into a somewhat weired problem and hope that this NG is able to help ;-)

I have a table in a MSSQL Server in which there is one Column that stores a date. The Format is 04.03.2004

Now I want to populate a Listbox but only with the year from that Column. So if I have lets say 10 entries with *.*.2004 and 5 with *.*.2003 I just want to show 2003 and 2004 once in the Listbox.
Basically intended for a Searchform to search for entries from a specific
year.
I can get the Listbox to display the years allright but if I have 1000
entries in the Column I gett as much in the Listbox.
This is the Code I have so far

<select name="select">
<%
While (NOT rsMyDate.EOF)
%>
<option value="<% Response.Write (Month
(rsMyDate.Fields.Item("Date").Value)) %>"><% Response.Write (Month
(rsMyDate.Fields.Item("Date").Value)) %></option>
<%
rsMyDate.MoveNext()
Wend
If (rsMyDate.CursorType > 0) Then
rsMyDate.MoveFirst
Else
rsMyDate.Requery
End If
%>
</select>
Any ideas are greatly appreciated.

Cheers

Btw..sorry 4 crossposting ;-)


Jul 19 '05 #4

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

Similar topics

1
by: cloverme | last post by:
Hi, I need help populating a listbox from a database on a webform. I created a an access database with a table, fields and data. Then I created a WebForm in vb.net and added a DropDownList...
0
by: Bill Brinkworth | last post by:
I want the user to type in part of a word, and I want to return all words from an Access word table that contains specified letters. If they were to type "fe??", it should return all words in the...
6
by: Deano | last post by:
I needed to have a listbox populated by locations which are stored in tblLocations. However I wanted an "All locations" entry to be at the top of the listbox. This is not in the tblLocations. The...
2
by: collie | last post by:
Hi, I have 2 listboxes. The first gets populated from the db as soon as the page loads. The second listbox get populated based on the user's selection from the first listbox. However,...
6
by: Chris Leuty | last post by:
I am populating a multiselect Listbox from a dataset, with the content of the listbox filled by one table, and the selections determined from another table. So far, I have been keeping the dataset...
6
by: P K | last post by:
I have a listbox which I am populating on the client (it contains a list of dates selected from calender). The listbox is a server control. When I get to the server after postback by selecting an...
15
by: NasirMunir | last post by:
I am trying to populate a listbox from another listbox on a access form. My first listbox has names of tables on a linked odbc databse. I am trying to display the tuples of the table in the second...
2
by: NvrBst | last post by:
I populate a ListBox with a LogFile that has about (~1000 lines). The ListBox's datasource is a BindingList<string>. Whenever I add the elements, with the datasource set, it takes about 2 mins. ...
1
by: dkohel | last post by:
I have 2 list boxes on my form. I am trying to populate listbox B with the selection from listbox A. I have set multi-select in both boxes to Extended... The user will select the items from...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....

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.