jackie77
Jackie
- Local time
- Today, 15:17
- Joined
- Jul 18, 2007
- Messages
- 85
Hi everyone
I am new to the forum and in fact new to access and VBA so I am apologize in advance for my stupidity. I am currently adapting a search example which was very kindly placed on this forum by Gromit called Search Form Example (Posted 12-28-2006) but I am having difficulty getting it to work the error message “Run-time error ‘3131’: Syntax error in FROM clause” the code I am using is:
-------------------------------------------------------------
Option Compare Database
Option Explicit
Private Sub btnClear_Click()
Dim intIndex As Integer
' Clear all search items
Me.txtBooked_Date = ""
Me.cmbEngineer = 0
End Sub
Private Sub btnSearch_Click()
' Update the record source
Me.frmsubClients.Form.RecordSource = "SELECT * FROM jobsheetquery " & BuildFilter
' Requery the subform
Me.frmsubClients.Requery
End Sub
Private Sub Form_Load()
' Clear the search form
btnClear_Click
End Sub
Private Function BuildFilter() As Variant
Dim varWhere As Variant
Dim varItem As Variant
Dim intIndex As Integer
varWhere = Null ' Main filter
' Check for LIKE Booked Date
If Me.txtBooked_Date > "" Then
varWhere = varWhere & "[Booked_Date] LIKE """ & Me.txtBooked_Date & "*"" AND "
End If
' Check for Engineer
If Me.cmbEngineer > 0 Then
varWhere = varWhere & "[Engineer] = " & Me.cmbEngineer & " AND "
End If
BuildFilter = varWhere
End Function
----------------------------------------------------
Any advice would be most appreciated
Thanks
Jackie
I am new to the forum and in fact new to access and VBA so I am apologize in advance for my stupidity. I am currently adapting a search example which was very kindly placed on this forum by Gromit called Search Form Example (Posted 12-28-2006) but I am having difficulty getting it to work the error message “Run-time error ‘3131’: Syntax error in FROM clause” the code I am using is:
-------------------------------------------------------------
Option Compare Database
Option Explicit
Private Sub btnClear_Click()
Dim intIndex As Integer
' Clear all search items
Me.txtBooked_Date = ""
Me.cmbEngineer = 0
End Sub
Private Sub btnSearch_Click()
' Update the record source
Me.frmsubClients.Form.RecordSource = "SELECT * FROM jobsheetquery " & BuildFilter
' Requery the subform
Me.frmsubClients.Requery
End Sub
Private Sub Form_Load()
' Clear the search form
btnClear_Click
End Sub
Private Function BuildFilter() As Variant
Dim varWhere As Variant
Dim varItem As Variant
Dim intIndex As Integer
varWhere = Null ' Main filter
' Check for LIKE Booked Date
If Me.txtBooked_Date > "" Then
varWhere = varWhere & "[Booked_Date] LIKE """ & Me.txtBooked_Date & "*"" AND "
End If
' Check for Engineer
If Me.cmbEngineer > 0 Then
varWhere = varWhere & "[Engineer] = " & Me.cmbEngineer & " AND "
End If
BuildFilter = varWhere
End Function
----------------------------------------------------
Any advice would be most appreciated
Thanks
Jackie