Rowsource changes on form load

  • Thread starter Thread starter Padraigini
  • Start date Start date
P

Padraigini

Hi,
I have a comcobox on a form that when the form loads it changes from what
has been saved/set as the row source.
I have checked all the VBA a associated with the code and can find any that
could cause this to happen. To clarify the code that I want in the rowsource
is??
SELECT EmployeeLastName
FROM (SELECT 0 AS Sort, "< all >" AS EmployeeLastName FROM TimeEntry UNION
SELECT 1, EmployeeLastName FROM TimeEntry)
Q ORDER BY Q.Sort, Q.EmployeeLastName;

Then for some reason it changes to
SELECT EmployeeLastName
FROM [SELECT 0 AS Sort, "< all >" AS EmployeeLastName FROM TimeEntry UNION
SELECT 1, EmployeeLastName FROM TimeEntry]
AS Q ORDER BY Q.Sort, Q.EmployeeLastName;
which generates the error
"The record source 'SELECT EmployeeLastName
FROM [SELECT 0 AS Sort, "< all >" AS EmployeeLastName FROM TimeEntry UNION
SELECT 1, EmployeeLastName...' specified on this form or report does not
exist.
It would be brilliant if someone could tell me what I might be doing wrong
or what I should change to stop this happening.
Thanks in Advance
 
Oh maybe this could help too my code for the change event of he combo box is
Private Sub cboLastName_Change()

If cboLastName.Value <> "<all>" Then
lstArea.RowSource = "SELECT Distinct TimeEntry.Area " & _
"FROM TimeEntry " & _
"WHERE TimeEntry.EmployeeLastName='" & Replace(cboLastName.Value,
"'", "''") & "'"
Else
lstArea.RowSource = "Select Distinct TimeEntry.Area " _
& "FROM TimeEntry " _
& "WHERE TimeEntry.EmployeeLastName = '" & cboLastName.Value &
"' " _
& "ORDER BY TimeEntry.Area;"
End If

End Sub
 
Back
Top