Hello,
I am a beginner with using Microsoft Access and with visual basic coding and I was wondering if I could get some help with some issues I have encountered. I would post a zip file of my entire database on here, but I am having issues loading it. I am trying to build a search option for my company's inventory of filters, but when I click the button to perform the search, "Run Time Error 3075 - Missing ), ] in query expression. The code is as follows.
Option Compare Database
Option Explicit
Private Sub cmdUnfilter_Click()
Dim intIndex As Integer
Me.cboType = Null
Me.cboMake = Null
Me.txtModel = ""
Me.cboLocation = Null
End Sub
Private Sub cmdFilter_Click()
Dim strInv As String
Dim lngLen As Long
If Len(Me.cboType & vbNullString) <> 0 Then
strInv = strInv & "[Type] = " & Chr(34) & Me.cboType & Chr(34)
End If
If Len(Me.cboMake & vbNullString) <> 0 Then
If Len(strInv) <> 0 Then
strInv = strInv & " AND [Make] = " & Chr(34) & Me.cboMake & Chr(34)
Else
strInv = "[Make] = " & Chr(34) & Me.cboMake & Chr(34)
End If
End If
If Len(Me.txtModel & vbNullString) <> 0 Then
If Len(strInv) <> 0 Then
strInv = strInv & " AND [Model] = " & Chr(34) & Me.txtModel & Chr(34)
Else
strInv = "[Model] = " & Chr(34) & Me.txtModel & Chr(34)
End If
End If
If Len(Me.cboLocation & vbNullString) <> 0 Then
If Len(strInv) <> 0 Then
strInv = strInv & " AND [Location] = " & Chr(34) & Me.cboLocation & Chr(34)
Else
strInv = "[Location] = " & Chr(34) & Me.cboLocation & Chr(34)
End If
End If
lngLen = Len(strInv) - 10
If lngLen <= 0 Then
MsgBox "No Records Found. Try Again", vbInformation, "Not Valid."
Else
strInv = Left$(strInv, lngLen)
Debug.Print strInv
Me.Filter = strInv
Me.FilterOn = True
End If
End Sub
In my "Filter Inventory" form, I have 3 combo boxes(cboMake, cboModel, and cboLocation) 1 text box (txtModel), 2 buttons (cmdFilter, cmdUnfilter) and I have one subform with information from my filter inventory table. Upon trying to run this information with just an item chosen in the Location combo box, the error is displayed and the immediate window in code builder displays [Location] = ". Any solutions would be greatly appreciated.
Also, in my sub-form, I have 200+ records, but it only shows one at a time. Is there any way I can get all of my records to show up just like my table shows, so that it is all on the form at first, then upon entering information into my search fields, the records are consolidated to only show information that matches all criteria I have entered. I just want to see all the results at once, and not have to scroll through with the arrows at the bottom of the sub form.
If anybody has the time to help me with any of these issues, that would be absolutely amazing. As of right now, I just don't know where to look to confront the issue and have run out of ideas as to how to fix the problem. Thanks a lot.
James