The problem is fairly complex. I have a table where I can add records. These records have several parts. Each record consists of ID, Date, Train Number and many more. I have a form where I can add records. This form has two pages. One for adding records ( this part works fine ) and then I have another form where I can search records by filtering. The filtering happens by using an options group with different options button. I added a button to this page to display the filtered records on another form. When I filter by ID everything works, when I filter by Date it works too so I thought the other options would work fine too, but if I filter by Train number it doesn't work. This is the fault message I get: Syntax error( misssing operator ) in query expression
'Train Number = Forms![Faults_Form]![Firsttrainnumber]' I have no idea why it doesn't work. Lets finish by adding some code. The date part works but the train number part doesn't.
Private Sub Search_Workorder_Button_Click()
On Error GoTo Err_Search_Workorder_Button_Click
Dim Filtervoorwaarde
Select Case Me![Filter_options_Frame]
Case 1
DoCmd.OpenForm "Faults_Overview_Form"
Case 2
' Als besturingselement blanco is, bericht weergeven.
If IsNull(Forms![Faults_Form]![Date1]) Then
strBer = "Insert a date in the textbox."
intStijl = vbOKOnly
strTitel = "Date selection"
MsgBox strBer, intStijl, strTitel
Forms![Faults_Form]![Date1].SetFocus
Else
Filtervoorwaarde = "Date = Forms![Faults_Form]![Date1]"
DoCmd.OpenForm "Faults_Overview_Form", , , Filtervoorwaarde
End If
Case 3
If IsNull(Forms![Faults_Form]![Firsttrainnumber]) Then
strBer = "Insert a train number (101-120) in the textbox."
intStijl = vbOKOnly
strTitel = "Train selection"
MsgBox strBer, intStijl, strTitel
Forms![Faults_Form]![Firsttrainnumber].SetFocus
Else
Filtervoorwaarde = "Train Number = Forms![Faults_Form]![Firsttrainnumber]"
DoCmd.OpenForm "Faults_Overview_Form", , , Filtervoorwaarde
End If
case 1 and 2 are working but case 3 is not.
Thanks