sql in unbound textbox

S

Song Su

I have 4 unbound text boxes. Can I put SQL statement as control source of
the text box?

I want my txtWinter text box to show following result:

SELECT TOP 1 Course.YYYY, Course.RUNDATE
FROM Course
WHERE (((Course.SEM)="0"));

and I want my txtSpring text box to show:

SELECT TOP 1 Course.YYYY, Course.RUNDATE
FROM Course
WHERE (((Course.SEM)="1"));

and similar for Summer and Fall

Thanks.
 
D

Douglas J. Steele

No, you can't. Even if you could, that SQL wouldn't work for a couple of
reasons:

1) You're trying to return 2 values
2) You're using TOP without an ORDER BY criteria

You can try using the DMax function. I'd give an example, but I don't know
which of the two fields you want to return, nor how to change the Where
criteria to handle the fact that you've eliminated one of the fields.
 
S

Song Su

here is the 1 value i need with order by:

SELECT DISTINCT TOP 1 Course.RUNDATE
FROM Course
WHERE (((Course.SEM)="0"))
ORDER BY Course.RUNDATE;
 
K

Klatuu

=DMax("[RUNDATE]", "Course", "[SEM] = '0'")


Song Su said:
here is the 1 value i need with order by:

SELECT DISTINCT TOP 1 Course.RUNDATE
FROM Course
WHERE (((Course.SEM)="0"))
ORDER BY Course.RUNDATE;
 
S

Song Su

thanks. it works!

Klatuu said:
=DMax("[RUNDATE]", "Course", "[SEM] = '0'")


Song Su said:
here is the 1 value i need with order by:

SELECT DISTINCT TOP 1 Course.RUNDATE
FROM Course
WHERE (((Course.SEM)="0"))
ORDER BY Course.RUNDATE;
 
Top