I have an MS Access form where the user can select up to four criteria to filter the records returned by a report. In the VBA, I'm trying to build my filter string dynamically based on which fields, if any, the user chose to filter by. The below code is giving me a "Block If without End If" error. What am I doing wrong here?
If (IsNull(frm!employee) = False) Then
strFilter = "Trainee_First_Name + ' ' + Trainee_Last_Name = '" & frm!employee & "'"
If IsNull(frm!sop) = False Then
strFilter = strFilter + " AND sop_number = '" & frm!sop & "'"""
End If
If IsNull(frm!revision) = False Then
strFilter = strFilter + " AND revision_number = '" & frm!revision & "'"
End If
If IsNull(frm!dept) = False Then
strFilter = strFilter + " AND department = '" & frm!dept & "'"
End If
Else
If (IsNull(frm!sop) = False) Then
strFilter = "sop_number = '" & frm!sop & "'"
If (IsNull(frm!employee) = False) Then
strFilter = "Trainee_First_Name + ' ' + Trainee_Last_Name = '" & frm!employee & "'"
End If
If IsNull(frm!revision) = False Then
strFilter = strFilter + " AND revision_number = '" & frm!revision & "'"
End If
If IsNull(frm!dept) = False Then
strFilter = strFilter + " AND department = '" & frm!dept & "'"
End If
Else
If (IsNull(frm!revision) = False) Then
strFilter = "revision_number = '" & frm!revision & "'"
If (IsNull(frm!employee) = False) Then
strFilter = " AND Trainee_First_Name + ' ' + Trainee_Last_Name = '" & frm!employee & "'"
End If
If IsNull(frm!sop) = False Then
strFilter = strFilter + " AND sop_number = '" & frm!sop & "'"""
End If
If IsNull(frm!dept) = False Then
strFilter = strFilter + " AND department = '" & frm!dept & "'"
End If
Else
If IsNull(frm!dept) = False Then
strFilter = "department = '" & frm!dept & "'"
If (IsNull(frm!employee) = False) Then
strFilter = " AND Trainee_First_Name + ' ' + Trainee_Last_Name = '" & frm!employee & "'"
End If
If IsNull(frm!sop) = False Then
strFilter = strFilter + " AND sop_number = '" & frm!sop & "'"""
End If
If IsNull(frm!revision) = False Then
strFilter = strFilter + " AND revision_number = '" & frm!revision & "'"
End If
End If
Any advice you could give me to improve this code would be appreciated.
That code avoids " AND " at the beginning of strFilter. However the logic is challenging to follow and it uses multiple variations on the same basic themes.
Use a simpler approach. You're interested in the values contained in 4 form controls:
frm!employee
frm!sop
frm!Revision
frm!dept
Examine each of them in turn and, for any which contain a value, add a segment starting with " AND " to strFilter. Afterwards, if strFilter contains any text, you know it starts with " AND " so you can simply discard the first 5 characters.
strFilter = vbNullString ' <- make it explicit
If Len(Trim(frm!employee) & vbNullString) > 0 Then
strFilter = strFilter & _
" AND Trainee_First_Name & ' ' & Trainee_Last_Name = '" & _
frm!employee & "'"
End If
If Len(Trim(frm!sop) & vbNullString) > 0 Then
strFilter = strFilter & " AND sop_number = '" & frm!sop & "'"
End If
If Len(Trim(frm!Revision) & vbNullString) > 0 Then
strFilter = strFilter & " AND revision_number = '" & _
frm!Revision & "'"
End If
If Len(Trim(frm!dept) & vbNullString) > 0 Then
strFilter = strFilter & " AND department = '" & frm!dept & "'"
End If
If Len(strFilter) > 0 Then
' discard " AND " from beginning of string
strFilter = Mid(strFilter, 6)
End If
MsgBox "strFilter ->" & strFilter & "<-"
The issue is that your else... if clause aren't terminated with end if. You either need to use ElseIf or
Else
If ...
End If
Else...
I've modified your code below to use the latter syntax. Notice the End If lines below.
Note: You don't need **, that's just to call attention to it in your code block!
If (IsNull(frm!employee) = False) Then
strFilter = "Trainee_First_Name + ' ' + Trainee_Last_Name = '" & frm!employee & "'"
If IsNull(frm!sop) = False Then
strFilter = strFilter + " AND sop_number = '" & frm!sop & "'"""
End If
If IsNull(frm!revision) = False Then
strFilter = strFilter + " AND revision_number = '" & frm!revision & "'"
End If
If IsNull(frm!dept) = False Then
strFilter = strFilter + " AND department = '" & frm!dept & "'"
End If
Else
If (IsNull(frm!sop) = False) Then
strFilter = "sop_number = '" & frm!sop & "'"
If (IsNull(frm!employee) = False) Then
strFilter = "Trainee_First_Name + ' ' + Trainee_Last_Name = '" & frm!employee & "'"
End If
If IsNull(frm!revision) = False Then
strFilter = strFilter + " AND revision_number = '" & frm!revision & "'"
End If
If IsNull(frm!dept) = False Then
strFilter = strFilter + " AND department = '" & frm!dept & "'"
End If
**End If**
Else
If (IsNull(frm!revision) = False) Then
strFilter = "revision_number = '" & frm!revision & "'"
If (IsNull(frm!employee) = False) Then
strFilter = " AND Trainee_First_Name + ' ' + Trainee_Last_Name = '" & frm!employee & "'"
End If
If IsNull(frm!sop) = False Then
strFilter = strFilter + " AND sop_number = '" & frm!sop & "'"""
End If
If IsNull(frm!dept) = False Then
strFilter = strFilter + " AND department = '" & frm!dept & "'"
End If
**End If**
Else
If IsNull(frm!dept) = False Then
strFilter = "department = '" & frm!dept & "'"
If (IsNull(frm!employee) = False) Then
strFilter = " AND Trainee_First_Name + ' ' + Trainee_Last_Name = '" & frm!employee & "'"
End If
If IsNull(frm!sop) = False Then
strFilter = strFilter + " AND sop_number = '" & frm!sop & "'"""
End If
If IsNull(frm!revision) = False Then
strFilter = strFilter + " AND revision_number = '" & frm!revision & "'"
End If
**End If**
End If
Related
I have a main form and a tabular sub form in it. I am applying multiple filters to filter my main form but my subform is linked with parent and child field property so I am able to apply filter on one field only.
How can I apply the same filters in my subform to what I have in my main form?
Below is my code to help you to understand:
Private Sub Filtermainform()
Dim strWhere As String
'Make string
If Nz(Me.Combo56, "") <> "" Then
If IsNumeric(Me.Combo56) Then
strWhere = strWhere & "[" & Me.Combo54 & "] = " & Me.Combo56 & " AND "
Else
strWhere = strWhere & "[" & Me.Combo54 & "] = '" & Me.Combo56 & "' AND "
End If
End If
If Nz(Me.Combo109, "") <> "" Then
If IsNumeric(Me.Combo109) Then
strWhere = strWhere & "[" & Me.Combo107 & "] = " & Me.Combo109 & " AND "
Else
strWhere = strWhere & "[" & Me.Combo107 & "] = '" & Me.Combo109 & "' AND "
End If
End If
If Nz(Me.Combo112, "") <> "" Then
If IsNumeric(Me.Combo112) Then
strWhere = strWhere & "[" & Me.Combo111 & "] = " & Me.Combo112 & " AND "
Else
strWhere = strWhere & "[" & Me.Combo111 & "] = '" & Me.Combo112 & "' AND "
End If
End If
If Nz(Me.Combo114, "") <> "" Then
If IsNumeric(Me.Combo114) Then
strWhere = strWhere & "[" & Me.Combo113 & "] = " & Me.Combo114 & " AND "
Else
strWhere = strWhere & "[" & Me.Combo113 & "] = '" & Me.Combo114 & "' AND "
End If
End If
If Nz(Me.Combo116, "") <> "" Then
If IsNumeric(Me.Combo116) Then
strWhere = strWhere & "[" & Me.Combo115 & "] = " & Me.Combo116 & " AND "
Else
strWhere = strWhere & "[" & Me.Combo115 & "] = '" & Me.Combo116 & "' AND "
End If
End If
If Nz(Me.Combo118, "") <> "" Then
If IsNumeric(Me.Combo118) Then
strWhere = strWhere & "[" & Me.Combo117 & "] = " & Me.Combo118 & " AND "
Else
strWhere = strWhere & "[" & Me.Combo117 & "] = '" & Me.Combo118 & "' AND "
End If
End If
If Nz(Me.Combo120, "") <> "" Then
If IsNumeric(Me.Combo120) Then
strWhere = strWhere & "[" & Me.Combo119 & "] = " & Me.Combo120 & " AND "
Else
strWhere = strWhere & "[" & Me.Combo119 & "] = '" & Me.Combo120 & "' AND "
End If
End If
If Nz(Me.Combo122, "") <> "" Then
If IsNumeric(Me.Combo122) Then
strWhere = strWhere & "[" & Me.Combo121 & "] = " & Me.Combo122 & " AND "
Else
strWhere = strWhere & "[" & Me.Combo121 & "] = '" & Me.Combo122 & "' AND "
End If
End If
If Nz(Me.Combo124, "") <> "" Then
If IsNumeric(Me.Combo124) Then
strWhere = strWhere & "[" & Me.Combo123 & "] = " & Me.Combo124 & " AND "
Else
strWhere = strWhere & "[" & Me.Combo123 & "] = '" & Me.Combo124 & "' AND "
End If
End If
'Apply filter
If strWhere <> "" Then
strWhere = Left(strWhere, Len(strWhere) - 5) 'Remove the extra AND
Me.Filter = strWhere
Me.FilterOn = True
Else
Me.Filter = ""
Me.FilterOn = False
End If
You can have multiple fields in the MasterField and ChildField specification, like:
[Id];[FilterField]
[FK];[FilterField]
To remove the filter, double the first field, as you cannot modify either specification to have another count of fields than the other(!), thus:
[Id];[Id]
[FK];[FK]
So I've got the code below (not all of it is grey for some reason)
Private Sub CmdEdit_Click()
Me.Tableinform.Requery
Dim rs As DAO.Recordset
Set rs = Me.Tableinform.Form.RecordsetClone
'get data to textbox control
With rs
If .RecordCount > 0 Then
With Me.Tableinform.Form.Recordset
Me.ShowIDbox = .Fields("[ID]").Value
Me.CompbyDD = .Fields("[Received By]")
Me.Date1 = .Fields("[Date Received]")
Me.Date2 = .Fields("[Date Processed]")
Me.ReqType = .Fields("[Request Type]")
Me.InsName = .Fields("[Insured Name]")
Me.RiskNo = .Fields("[Risk Number]")
Me.EndtRef = .Fields("[Endorsement Reference]")
Me.EOCNo = .Fields("[EOC Number]")
Me.Tech = .Fields("[Technician]")
Me.BillIns = .Fields("[Billing Instructions]")
Me.Addrecord.Caption = "Update"
Me.CmdEdit.Enabled = False
Me.cmdDuplicate.Enabled = True
Me.CmdDelete.Enabled = True
End With
End If
End With
End Sub
After one Edit and Update, the edit function throws out Error '3021' No Current Record?
Please show me where I am going wrong with this.
Add/Update button as follows:
If Me.ShowIDbox.Value = "" Then
CurrentDb.Execute "INSERT INTO fmdatatable( [Received By], [Date Received], [Date Processed], [Request Type], [Insured Name], [Risk Number], [Endorsement Reference], [EOC Number], [Technician], [Billing Instructions]) " & _
" VALUES ('" & Me.CompbyDD & "','" & Me.Date1 & "','" & Me.Date2 & "','" & Me.ReqType & "','" & Me.InsName & "','" & Me.RiskNo & "','" & Me.EndtRef & "','" & Me.EOCNo & "','" & Me.Tech & "','" & Me.BillIns & "')"
Else
CurrentDb.Execute "UPDATE fmdatatable SET [Received By]='" & Me.CompbyDD & "'" & _
", [Date Received]='" & Me.Date1 & "'" & _
", [Date Processed]='" & Me.Date2 & "'" & _
", [Request Type]='" & Me.ReqType & "'" & _
", [Insured Name]='" & Me.InsName & "'" & _
", [Risk Number]='" & Me.RiskNo & "'" & _
", [Endorsement Reference]='" & Me.EndtRef & "'" & _
", [EOC Number]='" & Me.EOCNo & "'" & _
", [Technician]='" & Me.Tech & "'" & _
", [Billing Instructions]='" & BillIns & "'" & _
" WHERE [ID]=" & Me.ShowIDbox.Value
End If
Me.CompbyDD = "-Please Select-"
Me.Date1 = ""
Me.Date2 = ""
Me.ReqType = "-Please Select-"
Me.InsName = ""
Me.RiskNo = ""
Me.EndtRef = ""
Me.EOCNo = ""
Me.Tech = ""
Me.BillIns = "-Please Select-"
Me.ShowIDbox = ""
Me.Addrecord.Caption = "Add Record"
Me.CmdEdit.Enabled = True
Me.cmdDuplicate.Enabled = False
Me.CmdDelete.Enabled = False
Tableinform.Form.Requery
This edit works once, then all subsequent later edits are throwing errors out.
I am facing a little issue now. My issue is that currently when i made edit to the current record in my subform and click on "update" it will overwrite my previous record which i do not want.
Instead, I would like to add my edited data record from the subform and insert it into the subform as a new record with the same PO number as the one that i am editing.
Below are my code:
Private Sub cmdAdd_Click()
'when we click on button Add there are two options
'1. for insert
'2. for update
If Me.txtID.Tag & "" = "" Then
'this is for insert new
'add data to table
CurrentDb.Execute "INSERT INTO mxd " & _
"(ID,Fabrication,Width,FinishedGoods,Colour, " & _
"LabDipCode,GrossWeight,NettWeight, " & _
"Lbs,Loss,Yds,Remarks,POType,ComboName,GroundColour)" & _
" VALUES(" & Me.txtID & ",'" & Me.txtFabrication & "','" & _
Me.txtWidth & "','" & Me.txtFinishedGood & "','" & _
Me.txtColour & "','" & Me.txtLabDipCode & "','" & _
Me.txtGrossweight & "','" & _ Me.txtNettweight & "','" & _
Me.txtLbs & "','" & Me.txtLoss & "','" & _ Me.txtYds & "','" & _
Me.txtRemarks & "','" & Me.cboPoType "','" & _
Me.txtGroundColour & "','" & Me.txtComboName & "')"
Else
'otherwise (Tag of txtID store the id of student to be modified)
CurrentDb.Execute "UPDATE mxd " & _
" SET ID = " & Me.txtID & _
", Fabrication = '" & Me.txtFabrication & "'" & _
", Width = '" & Me.txtWidth & "'" & _
", FinishedGoods = '" & Me.txtFinishedGood & "'" & _
", Colour = '" & Me.txtColour & "'" & _
", LabDipCode = '" & Me.txtLabDipCode & "'" & _
", GrossWeight = '" & Me.txtGrossweight & "'" & _
", NettWeight = '" & Me.txtNettweight & "'" & _
", LBS = '" & Me.txtLbs & "'" & _
", Loss = '" & Me.txtLoss & "'" & _
", Yds = '" & Me.txtYds & "'" & _
", Remarks = '" & Me.txtRemarks & "'" & _
", POType = '" & Me.cboPoType & "'" & _
", ComboName = '" & Me.txtComboName & "'" & _
", GroundColour = '" & Me.txtGroundColour & "'" & _
" WHERE ID = " & Me.txtID.Tag
End If
'clear form
cmdClear_Click
'refresh data in list on form
FormMxdSub.Form.Requery
End Sub
Private Sub cmdClear_Click()
Me.txtID = ""
Me.txtFabrication = ""
Me.txtWidth = ""
Me.txtFinishedGood = ""
Me.txtColour = ""
Me.txtLabDipCode = ""
Me.txtGrossweight = ""
Me.txtNettweight = ""
Me.txtLbs = ""
Me.txtLoss = ""
Me.txtYds = ""
Me.txtRemarks = ""
Me.cboPoType = ""
Me.txtKeywords = ""
Me.txtComboName = ""
Me.txtGroundColour = ""
'focus on ID text box
Me.txtID.SetFocus
'set button edit to enable
Me.cmdEdit.Enabled = True
'change caption of button add to Add
Me.cmdAdd.Caption = "Add"
'clear tag on txtID for reset new
Me.txtID.Tag = ""
End Sub
Private Sub cmdClose_Click()
DoCmd.Close
End Sub
Private Sub cmdDelete_Click()
'delete record
'check existing selected record
If Not (Me.FormMxdSub.Form.Recordset.EOF And
Me.FormMxdSub.Form.Recordset.BOF) Then
'confirm delete
If MsgBox("Are you sure you want to delete?", vbYesNo) = vbYes Then
'delete now
CurrentDb.Execute "DELETE FROM mxd " & _
"where ID = " & Me.FormMxdSub.Form.Recordset.Fields("ID")
'refresh data in list
Me.FormMxdSub.Form.Requery
End If
End If
End Sub
Private Sub cmdEdit_Click()
'check whether there is exists data in list
If Not (Me.FormMxdSub.Form.Recordset.EOF And
Me.FormMxdSub.Form.Recordset.BOF) Then
'get data to text box control
With Me.FormMxdSub.Form.Recordset
Me.txtID = .Fields("ID")
Me.txtFabrication = .Fields("Fabrication")
Me.txtWidth = .Fields("Width")
Me.txtFinishedGood = .Fields("FinishedGoods")
Me.txtColour = .Fields("Colour")
Me.txtLabDipCode = .Fields("LabDipCode")
Me.txtGrossweight = .Fields("GrossWeight")
Me.txtNettweight = .Fields("NettWeight")
Me.txtLbs = .Fields("Lbs")
Me.txtLoss = .Fields("Loss")
Me.txtYds = .Fields("Yds")
Me.txtRemarks = .Fields("Remarks")
Me.cboPoType = .Fields("POType")
Me.txtComboName = .Fields("ComboName")
Me.txtGroundColour = .Fields("GroundColour")
'store id of student in Tag of txtID in case id is modified
Me.txtID.Tag = .Fields("ID")
'change caption of button add to update
'Me.cmdAdd.Caption = "Update"
'disable button edit
Me.cmdEdit.Enabled = False
End With
End If
End Sub
You can use the RecordsetClone to create a dupe of the current record. Much faster and cleaner and no Tag is needed:
Private Sub btnCopy_Click()
Dim rstSource As DAO.Recordset
Dim rstInsert As DAO.Recordset
Dim fld As DAO.Field
If Me.NewRecord = True Then Exit Sub
Set rstInsert = Me.RecordsetClone
Set rstSource = rstInsert.Clone
With rstSource
If .RecordCount > 0 Then
' Go to the current record.
.Bookmark = Me.Bookmark
With rstInsert
.AddNew
For Each fld In rstSource.Fields
With fld
If .Attributes And dbAutoIncrField Then
' Skip Autonumber or GUID field.
ElseIf .Name = "SomeFieldToExclude" Then
' Leave field blank.
ElseIf .Name = "SomeOtherFieldToExclude" Then
' Leave field blank.
Else
' Copy field content.
rstInsert.Fields(.Name).Value = .Value
End If
End With
Next
.Update
' Go to the new record and sync form.
.MoveLast
Me.Bookmark = .Bookmark
.Close
End With
End If
.Close
End With
Set rstInsert = Nothing
Set rstSource = Nothing
End Sub
Of course, if you place the button on the main form, replace in the code Me with a reference to the subform: Me!NameOfYourSubformControl.Form
I have created a table where I'm saving attachments(in external folder) and file paths in the table. When I'm trying to update existing attachment with another, it does not work. Please see below "Add file" code and "Update button" code.
Private Sub cmAdd_Click()
On Error Resume Next
Dim strLokacioni As String
Dim strSQL As String
strLokacioni = "C:\Users\HSE\Desktop\datas\" & getFileName(Me.path.Value)
strSQL = "INSERT INTO tbl_tracker(path, filename, IncNo, PATS, SAP, First, Last, IncDate, Description, Location, OshaType, IncType, RootCause,Inspector, Surfaces, WeatherCon, WorkRelated, IncTime)" & _
"VALUES ( '" & strLokacioni & "', '" & Me.path.Value & "', '" & Me.txtInc & "', '" & Me.txtPATS & "', '" & Me.txtSAP & "', '" & Me.txtFirst & "', '" & Me.txtLast & "', '" & Me.txtDate & "', '" & Me.txtDesc & "', '" & Me.cmbLoc & "', '" & Me.cmbOsha & "', '" & Me.cmbType & "', '" & Me.txtCause & "', '" & Me.cmbInsp & "', '" & Me.cmbSur & "', '" & Me.cmbWcon & "', '" & Me.cmbRelated & "', '" & Me.txtTime & "')"
CurrentDb.Execute (strSQL)
MsgBox "Record Added", vbInformation, "Information"
Dim fso As Object
Set fso = VBA.CreateObject("Scripting.FileSystemObject")
fso.CopyFile Me.path.Value, strLokacioni
Set fso = Nothing
Me.tbl_tracker_subform.Form.Requery
End Sub
' Below is update button code
Private Sub Command88_Click()
'On Error Resume Next
Dim strLokacioni As String: strLokacioni = "C:\Users\HSE\Desktop\datas\" & getFileName(Me.path.Value)
Me.path = strLokacioni
CurrentDb.Execute "UPDATE tbl_tracker " & _
" SET IncNo = " & Me.txtInc & _
", path = '" & strLokacioni & "'" & _
", filename = '" & Me.filename & "'" & _
", PATS = '" & Me.txtPATS & "'" & _
", SAP = '" & Me.txtSAP & "'" & _
", First = '" & Me.txtFirst & "'" & _
", Last = '" & Me.txtLast & "'" & _
", IncDate = '" & Me.txtDate & "'" & _
", Location = '" & Me.cmbLoc & "'" & _
", Description = '" & Me.txtDesc & "'" & _
", OshaType = '" & Me.cmbOsha & "'" & _
", Inctype = '" & Me.cmbType & "'" & _
", RootCause = '" & Me.txtCause & "'" & _
", Inspector = '" & Me.cmbInsp & "'" & _
", Surfaces = '" & Me.cmbSur & "'" & _
", WeatherCon = '" & Me.cmbWcon & "'" & _
", WorkRelated = '" & Me.cmbRelated & "'" & _
", IncTime = '" & Me.txtTime & "'" & _
" WHERE IncNo = " & Me.txtInc.Tag
Dim fso As Object
Set fso = VBA.CreateObject("Scripting.FileSystemObject")
fso.CopyFile Me.path.Value, strLokacioni
Set fso = Nothing
MsgBox "Record Updated", vbInformation, "Information"
Me.tbl_tracker_subform.Form.Requery
End sub
And the the value Me.path.Value at the start of Command88_click is coming from :
Public Function getFileName(ByVal strPath As String) As String
If Right$(strPath, 1) <> "\" And Len(strPath) > 0 Then
getFileName = getFileName(Left$(strPath, Len(strPath) - 1)) + Right$(strPath, 1)
End If
End Function
Private Sub cbdBrowse_Click()
On Error Resume Next
Dim f As Object
Set f = Application.FileDialog(msoFileDialogFilePicker)
f.AllowMultiSelect = False
f.Show
Me.path.Value = f.SelectedItems(1)
End Sub
When I use update queries like you have here, I would always use the following syntax.
dim db as database
set db = currentDb
db.execute "UPDATE...."
would you require the same? Or have I been going about this a long way.
Also, I would have left a comment as this may not be the answer. Unfortunately, I cant due to rep<50
The strFilter results in the following, but will not carry through to the Me.Filter, any ideas why?
strFilter = "'20410' OR 'A20000' OR 'A20400'"
Private Sub Image_OffsetFilterButton_Click()
Dim strFilter As String
strFilter = "'A20410'"
'/ see if there is data in Field Box Text907, if so add it to the filter
If Me!Text907 & vbNullStr <> vbNullStr Then
strFilter = strFilter & " OR " & "'" & "A20000" & "'"
End If
If Me!Text910 & vbNullStr <> vbNullStr Then
' If FieldB is of Text type, use the ' delimiter
strFilter = strFilter & " OR " & "'" & "A20024" & "'"
End If
If Me!Text911 & vbNullStr <> vbNullStr Then
' If FieldB is of Text type, use the ' delimiter
strFilter = strFilter & " OR " & "'" & "A20400" & "'"
End If
'/<etc>
If strFilter <> "" Then
' trim off leading "OR"
Me.Filter = "[Account] = strFilter AND [BU] = 'B50931'"
Me.FilterOn = True
Else
Me.Filter = ""
Me.FilterOn = False
End If
End Sub
Private Sub Image_OffsetFilterButton_Click()
Dim strFilter As String
strFilter = ""
'/ see if there is data in Field Box Text907, if so add it to the filter
If Me!Text907 & vbNullStr <> vbNullStr Then
strFilter = strFilter & " OR [ACCOUNT] = '" & Me.Text907 & "'"
End If
If Me!Text910 & vbNullStr <> vbNullStr Then
'/ If FieldB is of Text type, use the ' delimiter
strFilter = strFilter & " OR [ACCOUNT] = '" & Me.Text910 & "'"
End If
If Me!Text911 & vbNullStr <> vbNullStr Then
'/ If FieldB is of Text type, use the ' delimiter
strFilter = strFilter & " OR [ACCOUNT] = '" & Me.Text911 & "'"
End If
'/<etc>
If strFilter <> "" Then
'\ trim off leading "OR"
Me.Filter = Mid(strFilter, 4)
Me.FilterOn = True
Else
Me.Filter = "[BU] = [Forms]![Frm_Main]! [Frm_Main_TextBox_Display_BU_Number_HIDDEN].Value"
Me.FilterOn = False
End If
End Sub