By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,561 Members | 3,083 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,561 IT Pros & Developers. It's quick & easy.

Problems with Listbox Rowsource in MS Access 2003

P: 4
I have created a form in my database that resembles a calendar. I have 42 textboxes that display the day of the week for whatever month and year is selected in the combo boxes at the top of the form. The text boxes are named Text1, Text2, etc. The combo boxes are named cboYear and cboMonth.

Here is the problem: I put a listbox under each textbox that should show the project# for the projects that are active on that day. I'm using 3 fields from my Projects table in the query: Project#, ProjectStart, ProjectFinish. Project# is an autonumber field and is the primary key for the Projects table. ProjectStart and ProjectFinish are date/time fields. Basically, what each listbox should return is the Project# for all projects between the ProjectStart and ProjectFinish date.

I have tried everything that I can think of to make this work. Everytime I run a query it tells me that it is too complex. Here are the details I've tried as rowsource and as a query:

SELECT Projects.[Project#] FROM Projects WHERE (((DateSerial([cboYear],[cboMonth],[Text1])) Between Projects.ProjectStart And Projects.ProjectFinish));

I cannot imagine that this query is too complex for Access to work with. I have been staring at this for three days but have had no luck. Any suggestions you can offer are greatly appreciated. Thanks!
Jul 25 '07 #1
Share this Question
Share on Google+
6 Replies

Expert Mod 10K+
P: 12,366
To reference a value on a form you need to use Forms!FormName!ControlName
Jul 25 '07 #2

P: 4
How do I go about doing that?

I don't know how to rephrase the syntax to fit that in.
Jul 25 '07 #3

Expert Mod 10K+
P: 12,366
Well, instead of cboYear you use Forms!FormName!cboYear. The same goes for cboMonth and Text1.
Jul 25 '07 #4

P: 4

I have exhausted all the possible ways to write a rowsource for this listbox. NOTHING is working. Nothing. I have tried to write it by refering to the controls on the form like you suggested and nothing. I tried to write it without using Forms!FormName!Control and still nothing. In fact, all this listbox seems capable of returning is nothing. Here is my current rowsource syntax:

SELECT Projects.[Project#], ProjectStart, ProjectEnd FROM Projects WHERE ((Forms!Calendar!Text3) Between Projects.ProjectStart And Projects.ProjectEnd) ORDER BY Projects.[Project#];

This is where I am now, I cannot think of any other way to do this and it's driving me crazy. Any suggestions are very much appreciated. THANK YOU!
Aug 6 '07 #5

P: 4
Oh, and Text3 is equal to this:


And Text6 is equal to this:

Aug 6 '07 #6

Expert Mod 10K+
P: 12,366
Assuming the following:

1) You have 2 combo boxes named cboYear and cboMonth.

2) You have a textbox named txtDay.

3) You have a listbox named lstProjects.

4) They are all on the form Form1.

5) You want the listbox to list all projects that fall on the chosen date.

Then you do the following.

1) The listbox row source is:
SELECT WhatEverColumnsYouWant FROM SomeTable WHERE ProjectStartDate <= CDate(Forms!Form1!cboMonth & "/" & Forms!Form1!txtDay & "/" & Forms!Form1!cboYear) AND ProjectEndDate >= CDate(Forms!Form1!cboMonth & "/" & Forms!Form1!txtDay & "/" & Forms!Form1!cboYear)

2) In the AfterUpdate event of the two comboboxes and text box you requery the list box.
Aug 6 '07 #7

Post your reply

Sign in to post your reply or Sign up for a free account.