sql in unbound textbox

  • Thread starter Thread starter Song Su
  • Start date Start date
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.
 
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.
 
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;
 
=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;
 
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;
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top