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

MS Access dynamically change a table in a query for a report

Hi, I need to be pointed in the right direction. I'm looking for a way
to dynamically change a table in a query. I have a table called
students and each fiscal year the student table will get rolled to a
new table student2004. Currently all the reports are based on queries
using the student table. I would like to give the user the option to
pick a report and then pick the fiscal i.e. 2004 and then have the
query table change dynamically to student2004. Thanks for you help in
advanced.

Nov 13 '05 #1
3 2439

You need to change the SQL statement for the query. Code snippet
(requires reference to Microsoft DAO 3.6 Object Library):

Dim rDB As DAO.Database
Dim rQdf As DAO.QueryDef

Set rDB = CurrentDB()
Set rQdf = rDB.QueryDefs("MyQuery")

rQdf.SQL = "SELECT * FROM student2004;"
rQdf.Close

That said, what you really have is a data normalization problem. I'll
let others in this group point the way to solving this for you.

-Ken

Nov 13 '05 #2
The best approach is to build a form that "prompts" the user.

Assuming that your report has a date field, then you just add a column to
the report query like:

MyYear:Year[DateField]

And, it is possible that you already have a year field (but, if you have a
date field..then you did not need the year field..did you!!).

Anyway, you then simply open the report using the where clause. Assuming
you have a text box on the prompt screen that gets the year from the user,
then you go:

strWhere = "MyYear = " & me.txtWhatYear
docmd.OpenReprot "mycoolRepot",acViewPreview,,strWhere

By use the reports "where" clause, you get dynamic conditions for the
sql..but don't have to modify the sql!!

You can see bunch of screen shots of example report prompt screens here, and
they all use the above idea:
http://www.attcanada.net/~kallal.msn.../ridesrpt.html

--
Albert D. Kallal (Access MVP)
Edmonton, Alberta Canada
pl*****************@msn.com
http://www.members.shaw.ca/AlbertKallal
Nov 13 '05 #3
Thank you both, I think I have what I need to start the process. Again
thanks.

Nov 13 '05 #4

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

Similar topics

14
by: Sean C. | last post by:
Helpful folks, Most of my previous experience with DB2 was on s390 mainframe systems and the optimizer on this platform always seemed very predictable and consistent. Since moving to a WinNT/UDB...
30
by: Andante.in.Blue | last post by:
I just browsed through some of my Access links when I came across the Ten Commandments of Access (http://www.mvps.org/access/tencommandments.htm). Some of the points I heartily agree with (and...
3
by: CSDunn | last post by:
Hello, I have a situation with MS Access 2000 in which I need to display report data in spreadsheet orientation (much like a datasheet view for a form). If you think of the report in terms of what...
4
by: Sami | last post by:
I hope someone will tell me how to do this without having to do any VB as I know nothing in that area. I am a rank beginner in using Access. I have created a database consisting of student...
9
by: Colin McGuire | last post by:
Hi, I have an report in Microsoft Access and it displays everything in the table. One column called "DECISION" in the table has either 1,2, or 3 in it. On my report it displays 1, 2, or 3. I want...
6
by: Jarrod | last post by:
I have multiple reports in one database, on one form. I need to know what reports were run when, and by Network User ID. How do I do that?
7
by: manning_news | last post by:
I've got a report that's not sorting correctly. I build a SQL statement and assign it to the recordsource in the Open event, sorting the data the way the user chooses. The user can choose up to 3...
52
by: Neil | last post by:
We are running an Access 2000 MDB with a SQL 7 back end. Our network guy is upgrading to Windows Server 2003 and wants to upgrade Office and SQL Server at the same time. We're moving to SQL Server...
3
by: fperri | last post by:
I have a pivot query that is populated with rates returned based on options that user selects on a form. My issue is: They can either select one lender to see on the report, or a combination...
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
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:
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
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.