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

sql statement as a control source in Access reports

Hi everyone,

I am trying to use the expression builder to create input to a control
in an Access report.

I have a table called Records and I want to select the minimum date for
a record where the student = studentID..

The sql is pretty simple: "Select MIN(RecDate) from records_T where
studentID = 1".

Now, I have been trying to get this statement to work with the
expression builder, but no go!!

Is it possible to get this working someho with the expression builder
or supplying the SQL directly to the control source property??

Thanks,
Anja

Dec 7 '06 #1
4 18765
SQL cannot be used as Control Source; it can be used as Record Source for a
Form or Report, and a Field in the Record Source used as Control Source. A
Control Source may also be an expression, a constant, or a Function. The
DMIN Function may provide the information you want... I'd say chances are
slim to none that you actually want to specify the student id as a constant,
so you need to determine how you are going to obtain it... you may well need
to use VBA code to implement what you want.

If you could explain what it is that you have and what you are trying to
accomplish, not how you are trying to accomplish it (e.g., "use the
expression builder to create a control source"), perhaps someone could be
more helpful.

Larry Linson
Microsoft Access MVP
"Anja" <an*******@googlemail.comwrote in message
news:11**********************@73g2000cwn.googlegro ups.com...
Hi everyone,

I am trying to use the expression builder to create input to a control
in an Access report.

I have a table called Records and I want to select the minimum date for
a record where the student = studentID..

The sql is pretty simple: "Select MIN(RecDate) from records_T where
studentID = 1".

Now, I have been trying to get this statement to work with the
expression builder, but no go!!

Is it possible to get this working someho with the expression builder
or supplying the SQL directly to the control source property??

Thanks,
Anja

Dec 7 '06 #2

Larry Linson wrote:
SQL cannot be used as Control Source; it can be used as Record Source for a
Form or Report, and a Field in the Record Source used as Control Source. A
Control Source may also be an expression, a constant, or a Function. The
DMIN Function may provide the information you want... I'd say chances are
slim to none that you actually want to specify the student id as a constant,
so you need to determine how you are going to obtain it... you may well need
to use VBA code to implement what you want.

If you could explain what it is that you have and what you are trying to
accomplish, not how you are trying to accomplish it (e.g., "use the
expression builder to create a control source"), perhaps someone could be
more helpful.

Larry Linson
Microsoft Access MVP
"Anja" <an*******@googlemail.comwrote in message
news:11**********************@73g2000cwn.googlegro ups.com...
Hi everyone,

I am trying to use the expression builder to create input to a control
in an Access report.

I have a table called Records and I want to select the minimum date for
a record where the student = studentID..

The sql is pretty simple: "Select MIN(RecDate) from records_T where
studentID = 1".

Now, I have been trying to get this statement to work with the
expression builder, but no go!!

Is it possible to get this working someho with the expression builder
or supplying the SQL directly to the control source property??

Thanks,
Anja
Thanks for the reply. Well, I tried using the DLookup function and it
does not give me any errors. However, the date field that it is
supposed to return is formatted as some scientific expression!

So, my statement is:

=CStr(DLookUp(Min("[RecDate]"),"[Records_T]","[Student]=" &
Forms![Student Manager]!MM_GradesByStudent))

Dec 7 '06 #3

Anja wrote:
Larry Linson wrote:
SQL cannot be used as Control Source; it can be used as Record Source for a
Form or Report, and a Field in the Record Source used as Control Source. A
Control Source may also be an expression, a constant, or a Function. The
DMIN Function may provide the information you want... I'd say chances are
slim to none that you actually want to specify the student id as a constant,
so you need to determine how you are going to obtain it... you may well need
to use VBA code to implement what you want.

If you could explain what it is that you have and what you are trying to
accomplish, not how you are trying to accomplish it (e.g., "use the
expression builder to create a control source"), perhaps someone could be
more helpful.

Larry Linson
Microsoft Access MVP
"Anja" <an*******@googlemail.comwrote in message
news:11**********************@73g2000cwn.googlegro ups.com...
Hi everyone,
>
I am trying to use the expression builder to create input to a control
in an Access report.
>
I have a table called Records and I want to select the minimum date for
a record where the student = studentID..
>
The sql is pretty simple: "Select MIN(RecDate) from records_T where
studentID = 1".
>
Now, I have been trying to get this statement to work with the
expression builder, but no go!!
>
Is it possible to get this working someho with the expression builder
or supplying the SQL directly to the control source property??
>
Thanks,
Anja
>

Thanks for the reply. Well, I tried using the DLookup function and it
does not give me any errors. However, the date field that it is
supposed to return is formatted as some scientific expression!

So, my statement is:

=CStr(DLookUp(Min("[RecDate]"),"[Records_T]","[Student]=" &
Forms![Student Manager]!MM_GradesByStudent))
A bit more progress:

yet a bit more!

=CStr(CDate((DLookUp(Min("[StuDate]"),"[Records_T]","[Student]=" &

Forms![Student Manager]!SM_GradesByStudent)))

always returns 00:00::05!!

Anja

Dec 7 '06 #4
I'm not sure what I wrote that was unclear, but I do not see the DMin
function that I suggested in either of your followups.

The following Control Source works nicely to return the earliest order for
the customer selected in "cboCustomerID" on a Form whose RecordSource is the
Orders table from the Northwind sample database. The CustomerID in the
Orders table is a text Field, which is why the value must be in quotes in
the DMin statement.

=DMin("OrderDate","Orders","CustomerID = """ & [cboCustomerID] & """")

The DMin domain aggregate function has the purpose of finding and returning
the minimum value of a Field in a Domain -- see the Help. And if this fills
your needs, you don't need to explain what it is that you are trying to
accomplish, so we might suggest alternative approaches.

Larry Linson
Microsoft Access MVP
"Anja" <an*******@googlemail.comwrote in message
news:11*********************@n67g2000cwd.googlegro ups.com...
>
Anja wrote:
>Larry Linson wrote:
SQL cannot be used as Control Source; it can be used as Record Source
for a
Form or Report, and a Field in the Record Source used as Control
Source. A
Control Source may also be an expression, a constant, or a Function.
The
DMIN Function may provide the information you want... I'd say chances
are
slim to none that you actually want to specify the student id as a
constant,
so you need to determine how you are going to obtain it... you may well
need
to use VBA code to implement what you want.

If you could explain what it is that you have and what you are trying
to
accomplish, not how you are trying to accomplish it (e.g., "use the
expression builder to create a control source"), perhaps someone could
be
more helpful.

Larry Linson
Microsoft Access MVP
"Anja" <an*******@googlemail.comwrote in message
news:11**********************@73g2000cwn.googlegro ups.com...
Hi everyone,

I am trying to use the expression builder to create input to a
control
in an Access report.

I have a table called Records and I want to select the minimum date
for
a record where the student = studentID..

The sql is pretty simple: "Select MIN(RecDate) from records_T where
studentID = 1".

Now, I have been trying to get this statement to work with the
expression builder, but no go!!

Is it possible to get this working someho with the expression builder
or supplying the SQL directly to the control source property??

Thanks,
Anja

Thanks for the reply. Well, I tried using the DLookup function and it
does not give me any errors. However, the date field that it is
supposed to return is formatted as some scientific expression!

So, my statement is:

=CStr(DLookUp(Min("[RecDate]"),"[Records_T]","[Student]=" &
Forms![Student Manager]!MM_GradesByStudent))

A bit more progress:

yet a bit more!

=CStr(CDate((DLookUp(Min("[StuDate]"),"[Records_T]","[Student]=" &

Forms![Student Manager]!SM_GradesByStudent)))

always returns 00:00::05!!

Anja

Dec 7 '06 #5

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

Similar topics

7
by: mark | last post by:
Access 2000: I creating a report that has a record source built by the user who selects the WHERE values. An example is: SELECT * FROM CHARGELOG WHERE STDATE Between #10/27/2003# And...
4
by: kathy | last post by:
Working in a form, I have an Iif statement where if a date is not filled in, another field will show as a blank. If the date IS filled in, the 2nd field will show its actual value. The following...
2
by: Richard Holliingsworth | last post by:
Hello: How do you attac an SQL statement to an unbound forms (or reports) control in A2002? I created an unbound text box, and I want to attach the following SQL statement..... select...
2
by: tom.darci | last post by:
Hi All, We are hoping to setup source control for our Access XP development. We don't want to use Visual SourceSafe because (a) we often work remotely and (b) we hear bad things about...
2
by: bill | last post by:
I have the following user control in my project simply for setting focus to a control: Public Class SetFocus Inherits System.Web.UI.UserControl
14
by: MLH | last post by:
I use A97. I've gotten used to reading values from textbox controls on forms, I've come to rely on it pretty heavily. My habit spills over into reports. I'm uncertain whether I can reliably read...
2
by: Newbie | last post by:
I have a combobox on a form. Coming from VB, I like to build a dynamic SQL statement and then set the control's data source to the SQL statement. Please tell me how to do that in access using...
1
by: mycall | last post by:
Heyyas. I am trying to print out a report which lists account details and payment amounts from january to december. I have following tables: Payment(paymentNo, DateOwing, amount, accountID)...
0
by: angi35 | last post by:
In Access 2000, I'm trying to create a couple reports but can't figure out the queries. 1. In a form, I have a control with a dollar amount, with the source field . Then there's an option group...
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?
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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
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.