|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Cant see the sql error....
I have this code which looks fine to me, but access wont have it. Any offers??
Function BuildSQLString(strSQL As String) As Boolean Dim strSELECT As String, strFROM As String, strWHERE As String strSELECT = "[autostaff].[Initials], [autostaff].[Datestaff], [autostaff].[ID], [autostaff].[Pay], [autostaff].[contract], [autostaff].[number of jobs]" strFROM = "[autostaff]" strWHERE = " ((([autostaff].[Initials]) In (SELECT [Initials] FROM [autostaff] As Tmp GROUP BY [Initials],[Datestaff] HAVING Count(*)>=1 And [Date] = [autostaff].[Datestaff]) And ([autostaff].[Initials])<>!N/A)) " If Not IsNull(datestarttxt) Then strWHERE = strWHERE & " And [autostaff]![Datestaff] >= [Forms]![auto-staff]![datestarttxt]" If Not IsNull(enddatetxt) Then strWHERE = strWHERE & " And [autostaff]![Datestaff] <= [Forms]![auto-staff]![enddatetxt]" strSQL = "SELECT" & strSELECT strSQL = strSQL & "FROM " & strFROM If strWHERE <> "" Then strSQL = strSQL & "WHERE " & Mid$(strWHERE, 6) strSQL = strSQL & "ORDER BY" & "[auto-staff]![datestaff]" & "DESC" strSQL = strSQL BuildSQLString = True End Function |
|
#2
|
|||
|
|||
|
Three bits look odd:
The N/A section needs single quotes Don't understand the Mid$ section of strWhere "ORDER BY" needs a space front and back |
|
#3
|
|||
|
|||
|
Try these in addition to what sherrington advised
Put a space after the word SELECT strSQL = "SELECT " & strSELECT Remove the space before the last quote in strWHERE strWHERE = ".....And [Date] = [autostaff].[Datestaff]) And ([autostaff].[Initials])<>!N/A))" This extra space isn't accounted for in the Mid$ function. Be sure to correct the !N/A as suggested. lwells |
![]() |
| Viewing: Dev Articles Community Forums > Databases > Microsoft Access Development > Cant see the sql error.... |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|