G
Guest
Hello there,
Hopefully someone can assist me with this particular situation:
I have a search form that checks three text boxes to see if there is
anything entered in there, and then checks two more text boxes to set up a
date range for the search. However, when you enter the information and try to
run the search, the VB code is showing "Compile Error: Expected Array". I
haven't setup an array on this section of code, and I'm not sure as to why it
is asking for an Array. Is this something that I should be considering?????
Here is the code that I have:
Private Sub cmdSubmit_Click()
'Create variables for the search parameters
Dim txtAgentID, txtLnGroup, txtProgram As String
txtAgentID = Me.txtAgentID.Value
txtLnGroup = Me.txtLineGroup.Value
txtProgram = Me.txtSoftware.Value
'Check to see which field is filled in, and how to react to information
If txtAgentID = "" And txtLnGroup = "" And txtProgram = "" Then
MsgBox "No information was entered. Please Re-enter your information for
what your looking for. ", vbOKCancel, "Error Message"
Else
Dim strAgtID, strTxtAgtID As String
strAgtID = Me.txtAgentID.Value
strTxtAgtID = "SELECT AgentID, Date, Software, ProbDesc, LineGroup FROM
EOSMain WHERE EOSMain.[AgentID] = """ & strAgtID & """;"
Dim strLineGroup, strTxtLineGroup As String
strLineGroup = Me.txtLineGroup.Value
strTxtLineGroup = "SELECT AgentID, Date, Software, ProbDesc, LineGroup
FROM EOSMain WHERE EOSMain.[LineGroup] =""" & strLineGroup & """;"
Dim strProgram, txtPrgrm As String
strProgram = Me.txtSoftware.Value
strPrgrm = "SELECT AgentID, Date, Software, ProbDesc, LineGroup FROM
EOSMain WHERE EOSMain.[Software] =""" & strProgram & """;"
End If
' Create parameters for Date Selection
Dim strFilter As String
Dim IsDate As String
'Here is the section that I am having problems with:
If IsDate(Me.txtDateStart) And IsDate(Me.txtEndDate) Then
strFilter = "BETWEEN #" & Me.txtDateStart & "# And #" &_
Me.txtEndDate & "#"
ElseIf IsDate(Me.txtDateStart) And Not IsDate(Me.txtEndDate) Then
strFilter = ">= #" & Me.txtDateStart & "#"
ElseIf Not IsDate(Me.txtDateStart) And IsDate(Me.txtEndDate) Then
strFilter = "<= #" & Me.txtEndDate & "#"
End If
If Len(strFilter) = 0 Then 'No dates were entered, include everything
Me.FilterOn = False
Else0
Me.Filter = "EOSMain.[Date] " & strFilter
Me.FilterOn = True
End If
Me.Requery
'Take the above variables and send them to the correct Report
Dim stDocName As String
stDocName = "SoftwareSearch"
DoCmd.OpenReport stDocName, acPreview
Loop
End Sub
Any help would be appreciated.
Thank you
Hopefully someone can assist me with this particular situation:
I have a search form that checks three text boxes to see if there is
anything entered in there, and then checks two more text boxes to set up a
date range for the search. However, when you enter the information and try to
run the search, the VB code is showing "Compile Error: Expected Array". I
haven't setup an array on this section of code, and I'm not sure as to why it
is asking for an Array. Is this something that I should be considering?????
Here is the code that I have:
Private Sub cmdSubmit_Click()
'Create variables for the search parameters
Dim txtAgentID, txtLnGroup, txtProgram As String
txtAgentID = Me.txtAgentID.Value
txtLnGroup = Me.txtLineGroup.Value
txtProgram = Me.txtSoftware.Value
'Check to see which field is filled in, and how to react to information
If txtAgentID = "" And txtLnGroup = "" And txtProgram = "" Then
MsgBox "No information was entered. Please Re-enter your information for
what your looking for. ", vbOKCancel, "Error Message"
Else
Dim strAgtID, strTxtAgtID As String
strAgtID = Me.txtAgentID.Value
strTxtAgtID = "SELECT AgentID, Date, Software, ProbDesc, LineGroup FROM
EOSMain WHERE EOSMain.[AgentID] = """ & strAgtID & """;"
Dim strLineGroup, strTxtLineGroup As String
strLineGroup = Me.txtLineGroup.Value
strTxtLineGroup = "SELECT AgentID, Date, Software, ProbDesc, LineGroup
FROM EOSMain WHERE EOSMain.[LineGroup] =""" & strLineGroup & """;"
Dim strProgram, txtPrgrm As String
strProgram = Me.txtSoftware.Value
strPrgrm = "SELECT AgentID, Date, Software, ProbDesc, LineGroup FROM
EOSMain WHERE EOSMain.[Software] =""" & strProgram & """;"
End If
' Create parameters for Date Selection
Dim strFilter As String
Dim IsDate As String
'Here is the section that I am having problems with:
If IsDate(Me.txtDateStart) And IsDate(Me.txtEndDate) Then
strFilter = "BETWEEN #" & Me.txtDateStart & "# And #" &_
Me.txtEndDate & "#"
ElseIf IsDate(Me.txtDateStart) And Not IsDate(Me.txtEndDate) Then
strFilter = ">= #" & Me.txtDateStart & "#"
ElseIf Not IsDate(Me.txtDateStart) And IsDate(Me.txtEndDate) Then
strFilter = "<= #" & Me.txtEndDate & "#"
End If
If Len(strFilter) = 0 Then 'No dates were entered, include everything
Me.FilterOn = False
Else0
Me.Filter = "EOSMain.[Date] " & strFilter
Me.FilterOn = True
End If
Me.Requery
'Take the above variables and send them to the correct Report
Dim stDocName As String
stDocName = "SoftwareSearch"
DoCmd.OpenReport stDocName, acPreview
Loop
End Sub
Any help would be appreciated.
Thank you