Syntax Question

  • Thread starter Thread starter Mommio2
  • Start date Start date
M

Mommio2

Hello! I have this for the rowsource of a dropdown box on my form.
Findname is my query:

SELECT FindName.[Student_ Last_ Name] FROM FindName ORDER BY [Student_ Last_
Name];

This may be a dumb question, but I have tried it over and over and I always
get a syntax error. How about if I want to include Student_First_Name so
that last name, first name are shown in the box? How should I add that?

THANKS!

Mommio2
 
The SQL statement seems to have proper syntax, although either use FindName
in the ORDER BY clause too, or leave it out in the SELECT clause (watch for
line-wrapping):

SELECT FindName.[Student_ Last_ Name] FROM FindName ORDER BY
FindName.[Student_ Last_Name];

or

SELECT [Student_ Last_ Name] FROM FindName ORDER BY [Student_ Last_Name];

To include the first name field as well:

SELECT [Student_ Last_ Name], [Student_First_Name] FROM FindName ORDER BY
[Student_ Last_Name];

And then set Column Count property to 2, and set Column Widths property to
1";1" value.
 
THANKS!!!

Ken Snell (MVP) said:
The SQL statement seems to have proper syntax, although either use
FindName in the ORDER BY clause too, or leave it out in the SELECT clause
(watch for line-wrapping):

SELECT FindName.[Student_ Last_ Name] FROM FindName ORDER BY
FindName.[Student_ Last_Name];

or

SELECT [Student_ Last_ Name] FROM FindName ORDER BY [Student_ Last_Name];

To include the first name field as well:

SELECT [Student_ Last_ Name], [Student_First_Name] FROM FindName ORDER BY
[Student_ Last_Name];

And then set Column Count property to 2, and set Column Widths property to
1";1" value.
--

Ken Snell
<MS ACCESS MVP>


Mommio2 said:
Hello! I have this for the rowsource of a dropdown box on my form.
Findname is my query:

SELECT FindName.[Student_ Last_ Name] FROM FindName ORDER BY [Student_
Last_ Name];

This may be a dumb question, but I have tried it over and over and I
always get a syntax error. How about if I want to include
Student_First_Name so that last name, first name are shown in the box?
How should I add that?

THANKS!

Mommio2
 
Hello! I have this for the rowsource of a dropdown box on my form.
Findname is my query:

SELECT FindName.[Student_ Last_ Name] FROM FindName ORDER BY [Student_ Last_
Name];

This may be a dumb question, but I have tried it over and over and I always
get a syntax error. How about if I want to include Student_First_Name so
that last name, first name are shown in the box? How should I add that?

THANKS!

Mommio2

What is the name of the field?

Is it

Student_Last_Name

or is it

Student_ Last_ Name

?

Note that blanks ARE meaningful.

What do you intend to be the Bound Column of the combo box - the field
which will be stored in the Form's Table? Is there a StudentID? If so,
and if it's the field you want stored, try:

SELECT FindName.StudentID, [Student_Last_Name] & ", " &
[Student_First_Name] FROM FindName
ORDER BY [Student_Last_Name], [Student_First_Name];

and set the ColumnWidths property to 0;1.5.

It doesn't make much sense to me to have JUST the last name - or first
and last name - in the rowsource of a combo; you might have two or
more students with the same name!

John W. Vinson[MVP]
 
Back
Top