Re: Using SQL in Sub to fill box on mouseclick

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Your SQL statement is incorrect.

The WHERE clause comes before the GROUP BY clause.

>From the Help file:

SELECT [predicate] { * | table.* | [table.]field1 [AS alias1] [,
[table.]field2 [AS alias2] [, ...]]}
FROM tableexpression [, ...] [IN externaldatabase]
[WHERE... ]
[GROUP BY... ]
[HAVING... ]
[ORDER BY... ]

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)



"JayVZ" <jayvz@xxxxxxxxxxxxxxx> wrote in message
news:qJ9ge.46713$PA4.21447@xxxxxxxxxxxxxxxxxxxxxxxx
> In the form that I am working on, I have a number of text boxes that are
> filled with a query telling me which people are scheduled to work a shift.
> I also have a text box (I may need to make this a sub form, but would
> prefer not) where I want a list of all available employees for the
> specific shift to show. When I click, I want to see the list, so that I
> can make changes if needed and only chose those employees that are
> available for the shift.
>
> I have:
> Private Sub Ctl8a_4pb_Click()
> Me!txtAvailEmployees = "SELECT tblAvailabilities.Date, [First]+" "+[Last]
> AS [Full Name]
> FROM tblAvailabilities INNER JOIN tblStaff ON
> tblAvailabilities.EmployeeNum = tblStaff.EmployeeID
> GROUP BY tblAvailabilities.Date, [First]+" "+[Last],
> tblAvailabilities.Shift1
> HAVING (((tblAvailabilities.Shift1)=-1))
> WHERE tblAvailabilities.Date=[form]![frmScheduleEdit]![CalDate];"
> End Sub
>
> I get a syntax error. Is is even possible to pass SQL in a manner as this?
> If it is, where would I be messing up?
>


.



Relevant Pages

  • RE: Hide Subforms until Date Range in Main Form established
    ... The After Update Event is in regard to the SQL Statement ... The same date range then applies to the sub forms also. ... unbound fields in your main form: ...
    (microsoft.public.access.formscoding)
  • RE: Hide Subforms until Date Range in Main Form established
    ... The After Update Event is in regard to the SQL Statement ... The same date range then applies to the sub forms also. ... unbound fields in your main form: ...
    (microsoft.public.access.formscoding)
  • RE: Hide Subforms until Date Range in Main Form established
    ... The After Update Event is in regard to the SQL Statement ... The same date range then applies to the sub forms also. ... unbound fields in your main form: ...
    (microsoft.public.access.formscoding)
  • Re: Help with SQL statement
    ... > Dim Product As String, TarWgt As Double, FileNum As ... > Exit Sub ... Your SQL statement doesn't work because it is not an UPDATE you need to ... directly from the combo box's Columnto the other text boxes, ...
    (microsoft.public.access.modulesdaovba)
  • RE: Hide Subforms until Date Range in Main Form established
    ... The After Update Event is in regard to the SQL Statement ... The same date range then applies to the sub forms also. ... unbound fields in your main form: ...
    (microsoft.public.access.formscoding)