P
Priss
Can anyone tell me why I am getting error 3075? See code
below.
Option Compare Database
Private Function FilterData() As DAO.Recordset
On Error GoTo err_routine
Dim ErrorValue As String
Dim AppSysID As String
Dim SalesID As String
Dim FilterValue As String
Dim SQL As String
Dim rs As DAO.Recordset
Dim myDB As DAO.Database
' get the value of the Error from the combo box
Me.cboError.SetFocus
ErrorValue = Me.cboError.Text
' get the value of the AppSysID from the combo box
Me.cboAppID.SetFocus
AppSysID = Me.cboAppID.Text
' get the value of the SalesID from the combo box
Me.cboSalesID.SetFocus
SalesID = Me.cboSalesID.Text
' get an instance of the database
Set myDB = CurrentDb
' set up the filter
SQL = "SELECT * FROM [tblLSBO_5/10] "
If Len(Trim$(ErrorValue & "")) > 0 Then
' we have an error value
If Len(Trim$(AppSysID & "")) > 0 Then
' we have a app sys id
If Len(Trim$(SalesID & "")) > 0 Then
'we have a sales id
SQL = SQL & "where [Error]=" & ErrorValue & "
and [APP SYS ID]=" & AppSysID & " "
Else
' we do not have an app sys id
SQL = SQL & "where [Error]=" & ErrorValue
End If
' we do not have a error value
SQL = SQL & "where [Error]=" & ErrorValue & "
and [Sales ID] = " & SalesID & ""
End If
Else
'we do not have a sales id
If Len(Trim$(AppSysID & "")) > 0 Then
' we have a app sys id
SQL = SQL & "where [APP SYS ID]=" & AppSysID
Else
' we do not have an app sys id
' do not change the SQL
End If
End If
Set rs = myDB.OpenRecordset(SQL)
Set FilterData = rs
Exit Function
err_routine:
MsgBox "Error " & Err.Number & ": " & Err.Description,
vbOKOnly + vbInformation, "Error"
Set FilterData = Nothing
Exit Function
End Function
Private Sub cboAppID_AfterUpdate()
Set Me.Recordset = FilterData
End Sub
Private Sub cboError_AfterUpdate()
Set Me.Recordset = FilterData
End Sub
Private Sub cboSalesID_AfterUpdate()
Set Me.Recordset = FilterData
' Find the record that matches the control.
'Dim rs As Object
'Set rs = Me.Recordset.Clone
'rs.FindFirst "[Sales ID] = '" & Me![cboSalesID] & "'"
'Me.Bookmark = rs.Bookmark
End Sub
Private Sub cmdSwitchboard_Click()
On Error GoTo Err_cmdSwitchboard_Click
Dim stDocName As String
stDocName = "mrcSwitchBoard"
DoCmd.RunMacro stDocName
Exit_cmdSwitchboard_Click:
Exit Sub
Err_cmdSwitchboard_Click:
MsgBox Err.Description
Resume Exit_cmdSwitchboard_Click
End Sub
Private Sub cmdClose_Click()
On Error GoTo Err_cmdClose_Click
DoCmd.Close
Exit_cmdClose_Click:
Exit Sub
Err_cmdClose_Click:
MsgBox Err.Description
Resume Exit_cmdClose_Click
End Sub
Private Sub cmdEmail_Click()
On Error GoTo Err_cmdEmail_Click
Dim stDocName As String
stDocName = "mcrEmail"
DoCmd.RunMacro stDocName
Exit_cmdEmail_Click:
Exit Sub
Err_cmdEmail_Click:
MsgBox Err.Description
Resume Exit_cmdEmail_Click
End Sub
Private Sub cmdRefresh_Click()
On Error GoTo Err_cmdRefresh_Click
'Clear screen
cboError = ""
cboAppID = ""
cboSalesID = ""
'tblLSBO_5/10 subform=""
cboError.SetFocus
DoCmd.DoMenuItem acFormBar, acRecordsMenu, 5, ,
acMenuVer70
Exit_cmdRefresh_Click:
Exit Sub
Err_cmdRefresh_Click:
MsgBox Err.Description
Resume Exit_cmdRefresh_Click
End Sub
Private Sub txtDesc_AfterUpdate()
Me.txtDesc = Me![cboAppID]
End Sub
below.
Option Compare Database
Private Function FilterData() As DAO.Recordset
On Error GoTo err_routine
Dim ErrorValue As String
Dim AppSysID As String
Dim SalesID As String
Dim FilterValue As String
Dim SQL As String
Dim rs As DAO.Recordset
Dim myDB As DAO.Database
' get the value of the Error from the combo box
Me.cboError.SetFocus
ErrorValue = Me.cboError.Text
' get the value of the AppSysID from the combo box
Me.cboAppID.SetFocus
AppSysID = Me.cboAppID.Text
' get the value of the SalesID from the combo box
Me.cboSalesID.SetFocus
SalesID = Me.cboSalesID.Text
' get an instance of the database
Set myDB = CurrentDb
' set up the filter
SQL = "SELECT * FROM [tblLSBO_5/10] "
If Len(Trim$(ErrorValue & "")) > 0 Then
' we have an error value
If Len(Trim$(AppSysID & "")) > 0 Then
' we have a app sys id
If Len(Trim$(SalesID & "")) > 0 Then
'we have a sales id
SQL = SQL & "where [Error]=" & ErrorValue & "
and [APP SYS ID]=" & AppSysID & " "
Else
' we do not have an app sys id
SQL = SQL & "where [Error]=" & ErrorValue
End If
' we do not have a error value
SQL = SQL & "where [Error]=" & ErrorValue & "
and [Sales ID] = " & SalesID & ""
End If
Else
'we do not have a sales id
If Len(Trim$(AppSysID & "")) > 0 Then
' we have a app sys id
SQL = SQL & "where [APP SYS ID]=" & AppSysID
Else
' we do not have an app sys id
' do not change the SQL
End If
End If
Set rs = myDB.OpenRecordset(SQL)
Set FilterData = rs
Exit Function
err_routine:
MsgBox "Error " & Err.Number & ": " & Err.Description,
vbOKOnly + vbInformation, "Error"
Set FilterData = Nothing
Exit Function
End Function
Private Sub cboAppID_AfterUpdate()
Set Me.Recordset = FilterData
End Sub
Private Sub cboError_AfterUpdate()
Set Me.Recordset = FilterData
End Sub
Private Sub cboSalesID_AfterUpdate()
Set Me.Recordset = FilterData
' Find the record that matches the control.
'Dim rs As Object
'Set rs = Me.Recordset.Clone
'rs.FindFirst "[Sales ID] = '" & Me![cboSalesID] & "'"
'Me.Bookmark = rs.Bookmark
End Sub
Private Sub cmdSwitchboard_Click()
On Error GoTo Err_cmdSwitchboard_Click
Dim stDocName As String
stDocName = "mrcSwitchBoard"
DoCmd.RunMacro stDocName
Exit_cmdSwitchboard_Click:
Exit Sub
Err_cmdSwitchboard_Click:
MsgBox Err.Description
Resume Exit_cmdSwitchboard_Click
End Sub
Private Sub cmdClose_Click()
On Error GoTo Err_cmdClose_Click
DoCmd.Close
Exit_cmdClose_Click:
Exit Sub
Err_cmdClose_Click:
MsgBox Err.Description
Resume Exit_cmdClose_Click
End Sub
Private Sub cmdEmail_Click()
On Error GoTo Err_cmdEmail_Click
Dim stDocName As String
stDocName = "mcrEmail"
DoCmd.RunMacro stDocName
Exit_cmdEmail_Click:
Exit Sub
Err_cmdEmail_Click:
MsgBox Err.Description
Resume Exit_cmdEmail_Click
End Sub
Private Sub cmdRefresh_Click()
On Error GoTo Err_cmdRefresh_Click
'Clear screen
cboError = ""
cboAppID = ""
cboSalesID = ""
'tblLSBO_5/10 subform=""
cboError.SetFocus
DoCmd.DoMenuItem acFormBar, acRecordsMenu, 5, ,
acMenuVer70
Exit_cmdRefresh_Click:
Exit Sub
Err_cmdRefresh_Click:
MsgBox Err.Description
Resume Exit_cmdRefresh_Click
End Sub
Private Sub txtDesc_AfterUpdate()
Me.txtDesc = Me![cboAppID]
End Sub