ODBC--call failed: Error 3146

ForcedToUseIt

Registered User.
Local time
Today, 19:18
Joined
Jul 25, 2004
Messages
34
I have the following problem: I use a filter in my form to filter continuous records and while the filter is on I want to be able to duplicate a record but Im having trouble with that. the following code is my filter and the error happens on the line:
Me.Filter = strFilter
When I try to duplicate a record with the filter on.

This is the code for the filter:
Code:
Public Sub DefineFilter()
  Dim Area As Variant
  Dim Dics As Variant
  Dim Prep As Variant
  Dim numbLen As Long
  Dim numbValue As String
  Dim strFilter As String
    
  strFilter = ""
  Me.combFilterCustomer.SetFocus
  If Len(Me.combFilterCustomer.Text) > 0 Then
    strFilter = "CustomerID= " & Me.combFilterCustomer.Value
  End If
  
  Me.combFilterArea.SetFocus
  If Len(Me.combFilterArea.Text) > 0 Then
    If Len(strFilter) > 0 Then
      strFilter = strFilter & " AND "
    End If
    strFilter = strFilter & "AreaNo='" & Me.combFilterArea.Text & "'"
  End If
  
  Me.combFilterDisc.SetFocus
  If Len(Me.combFilterDisc.Text) > 0 Then
    If Len(strFilter) > 0 Then
      strFilter = strFilter & " AND "
    End If
    strFilter = strFilter & "DiscNo='" & Me.combFilterDisc.Text & "'"
  End If
       
  Me.txtFilterNumber.SetFocus
  numbValue = Me.txtFilterNumber.Text
  numbLen = Len(Me.txtFilterNumber.Text)
  If (numbLen > 0) Then
    If Len(strFilter) > 0 Then
      strFilter = strFilter & " AND "
    End If
      strFilter = strFilter & "((Left([Number]," & numbLen & ")='" & numbValue & "'))"
  End If
       
  If Len(strFilter) > 0 Then
    Me.Filter = strFilter
    Me.FilterOn = True
  Else
    Me.FilterOn = False
  End If
  
End Sub

And this is the code for the duplicate button (the error happens when I press it):
Code:
Private Sub butDupicate_Click()
On Error GoTo Err_butDupicate_Click
      '8 = acSelectRecord
      DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
      DoCmd.DoMenuItem acFormBar, acEditMenu, 2, , acMenuVer70
      DoCmd.DoMenuItem acFormBar, acEditMenu, 5, , acMenuVer70 'Paste Append

Exit_butDupicate_Click:
    Exit Sub

Err_butDupicate_Click:
    MsgBox Err.Description
    Resume Exit_butDupicate_Click
    
End Sub
BTW the duplicate button works fine when the filter is not on.
I think that this problem is because when the filter is on, Im probably working on a different recordset than when im using the button without filters.

Any help will be greatly appreciated.
 

Users who are viewing this thread

Back
Top Bottom