473,386 Members | 1,997 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,386 software developers and data experts.

List Box on Form

Hello,

I have a List Box in my DB on a form, which when the form is opened,
the list box displays the date relating to the records. (Date, Person
etc)

How can I get it so that when I open the form, ONLY the records with a
date within the current month are shown.

Thanks in advance.

J.
Nov 13 '05 #1
5 1904
for the lookup box (using the properties)
set to two columns
set the column widths to 0;10cm

set the rowsource to

SELECT [your ID field] AS 1, [your description] AS 2
FROM [your table]
WHERE (((DatePart("m",[your date field]))=DatePart("m",Date())));

and make sure that you replace the 'your fields' and table with the proper
names.

Any questions, please ask.
Nov 13 '05 #2
On 15 Jun 2004 03:39:28 -0700, Jonny wrote:
Hello,

I have a List Box in my DB on a form, which when the form is opened,
the list box displays the date relating to the records. (Date, Person
etc)

How can I get it so that when I open the form, ONLY the records with a
date within the current month are shown.

Thanks in advance.

J.


I assume you mean the current month of the just the current year, not
previous years as well.

Base the List Box Row Source on a Query.
Set the criteria on the Date Field to:
Format([DateField],"mm yyyy")=Format(Date(),"mm yyyy")

Only June 2004 dates will appear this month.
--
Fred
Please only reply to this newsgroup.
I do not reply to personal email.
Nov 13 '05 #3
"Jonny" <jo**********@yahoo.com> wrote in message
news:14*************************@posting.google.co m...
Hello,

I have a List Box in my DB on a form, which when the form is opened,
the list box displays the date relating to the records. (Date, Person
etc)

How can I get it so that when I open the form, ONLY the records with a
date within the current month are shown.

you shouldn't use "Date" as a column name. Try something like this:

select hireDate, personName
from jonny
where hireDate >= CDate(Month(Date()) & "/01/" & Year(Date()))
and hireDate < DateAdd ("m",1,CDate(Month(Date()) & "/01/" & Year(Date())))
Nov 13 '05 #4
J,
In the properties of your list box set your row source to run from a
query based on the appropriate data table. In the query select the
fields you want to display in the order you wish them to appear in
your list box.

Add an exrta field into your query:
Field: DatePart("m",[DateField])
Criteria: DatePart("m",Date())
Untick the Show: check box

Baisically, you're limiting the list to only records where
month of [DateField] = month of the current date.

Similarly, you could use any date value in place of Date(), a field on
your form for example.

Hope this helps

K

jo**********@yahoo.com (Jonny) wrote in message news:<14*************************@posting.google.c om>...
Hello,

I have a List Box in my DB on a form, which when the form is opened,
the list box displays the date relating to the records. (Date, Person
etc)

How can I get it so that when I open the form, ONLY the records with a
date within the current month are shown.

Thanks in advance.

J.

Nov 13 '05 #5
ka********@northernrock.co.uk (Katie) wrote in message news:<43*************************@posting.google.c om>...
J,
In the properties of your list box set your row source to run from a
query based on the appropriate data table. In the query select the
fields you want to display in the order you wish them to appear in
your list box.

Add an exrta field into your query:
Field: DatePart("m",[DateField])
Criteria: DatePart("m",Date())
Untick the Show: check box

Baisically, you're limiting the list to only records where
month of [DateField] = month of the current date.

Similarly, you could use any date value in place of Date(), a field on
your form for example.

Hope this helps

K

jo**********@yahoo.com (Jonny) wrote in message news:<14*************************@posting.google.c om>...
Hello,

I have a List Box in my DB on a form, which when the form is opened,
the list box displays the date relating to the records. (Date, Person
etc)

How can I get it so that when I open the form, ONLY the records with a
date within the current month are shown.

Thanks in advance.

J.


Hello,

I have created a query in the rowsource of the list box, and it works
fine from within the query builder.
However, it doesn't work when I open the form.

I have a feeling it is because when the form it opened, it is already
set to do the following :

----------------------------------------
Private Sub Form_Open(Cancel As Integer)
Dim strsql As String
strsql = "SELECT ID,Person,Task,Area,DateFrom,DateTo FROM TblMain
WHERE 1 = 1"
If Len(TxtDateFrom) > 0 Then
strsql = strsql & " AND DateFrom like '*" & TxtDateFrom & "*'"
End If
If Len(TxtPerson) > 0 Then
strsql = strsql & " AND Person like '*" & TxtPerson & "*'"
End If
If Len(TxtTask) > 0 Then
strsql = strsql & " AND Task like '*" & TxtTask & "*'"
End If
If Len(TxtDateTo) > 0 Then
strsql = strsql & " AND DateTo like '*" & TxtDateTo & "*'"
End If

strsql = strsql & " Order by Person;"
Lstcustomers.RowSource = strsql
Call Countrecords
LblDateTime.Caption = Time
PersonSort.Visible = True
TaskSort.Visible = False
AreaSort.Visible = False
DateFromSort.Visible = False
DateToSort.Visible = False
Call CmdClear_Click
End Sub
---------------------------------------

Also, just to give you bit of background as to the code itself :

1) WHERE 1=1 is used because on this list form I have 3 boxes at the
top. (criteria boxes if you like). I put my name in one of these
boxes, then it filters the list box to only show my records. Then I
filer further by choosing a certain person, and it shows my records
with this person.

Without the WHERE 1=1, it would filter out my records, but when I then
chose a person, it showed others people's records with that person
aswell.

2) I have tried to put this on the onLoad event, but I got a message
saying "The expression On Load you entered as the event property
setting produced the following error : procedure declaration does not
match description of event or procedure having the same name."

I then choose ok to this, the form comes up (with the correct
records), then I get the same message again, but relating to the on
timer instead of the on load (on timer only populates a lable with
todays date and time)
I hope this makes sense, if not then please let me know.

Thanks.

J.
Nov 13 '05 #6

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

Similar topics

19
by: William Wisnieski | last post by:
Hello Everyone, I have a main form with a datasheet subform that I use to query by form. After the user selects two criteria on the main form and clicks the cmdShowResults button on the main...
8
by: Galina | last post by:
Hello I have 6 dependent list boxes on my ASP page:  Faculty;  Lecturer;  Course;  Course occurrence;  Group;  Week commencing date. When faculty is selected, lists of lecturers and...
0
by: Brian Henry | last post by:
Here is another virtual mode example for the .NET 2.0 framework while working with the list view. Since you can not access the items collection of the list view you need to do sorting another...
6
by: AA Arens | last post by:
Hi, I have a database with 2 main forms. Contacts and companies. I share the base with two others via LAN. On the companies form I have buttons to navigate throught the records (>400). We are...
3
by: rhobson2 | last post by:
Hello, I wrote a database applicaiton using Access XP (2002) and everything has been working good for the client until they purchased a couple of new computers with Access 2003. The meetings...
7
chunk1978
by: chunk1978 | last post by:
hello. so i have 2 select menus which add and remove options from a 3rd select menu... it seems, however, that it's not possible to use different select menus to toggle a 3rd, because when an...
4
Rabbit
by: Rabbit | last post by:
Cascading Combo/List Boxes This tutorial is to guide you in the creation of Cascading combo/list boxes. That is when you have multiple combo/list boxes where the selection of an option in one...
1
by: troy_lee | last post by:
I have a form (Form A) with a list box. Underneath the list box is a command button that minimizes Form A and opens up Form B. When the user is done with Form B, its exit button selects the...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
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...

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.