I have a form with a button that, when pressed, opens another form with a filter based on the record from the first form. The problem is that the filter doesn't seem to be working. Instead of showing only certain records, it's showing all records. I have checked at various points to make sure the filter is there and have requeried at different points too, all to no avail. Basically, these are the lines in the onclick event to open the form:
Here is the code for onactivate of the form being opened. I have used the code in the open and load events as well with no success.
I have no idea why the filter isn't applying. If anybody knows that might be the answer to this problem, it would be greatly appreciated. Thanks.
Code:
Dim stLinkCriteria As String
stLinkCriteria = "[repairdataID]=" & Me.[RepairID]
stDocName = "ReplacedPart"
DoCmd.OpenForm stDocName, WhereCondition:=stLinkCriteria, DataMode:=acFormReadOnly
Code:
Private Sub Form_Activate()
Debug.Print Me.RepairDataID & " - " & Me.RecordsetClone.RecordCount
'debug contents of recordset
Debug.Print "***********"
Do While Not Me.RecordsetClone.EOF
Debug.Print Me.RecordsetClone.Fields(2)
Me.RecordsetClone.MoveNext
Loop
If Me.RecordsetClone.RecordCount < 1 Then
'MsgBox "hi"
Me.AllowAdditions = True
Me.DataEntry = True
'MsgBox "hi"
'Me.RemovedPN.SetFocus
Me.buttonnew.Visible = False
Me.ButtonClose.Visible = True
Debug.Print Me.RepairDataID & " - " & Me.RecordsetClone.RecordCount
'if there are items to display
Else
'MsgBox "bad"
Me.DataEntry = False
Me.AllowAdditions = False
Me.buttonnew.Visible = True
Me.ButtonClose.Visible = False
End If
'Set rst = Nothing
'MsgBox Me.DataEntry
Debug.Print "----------"
End Sub
I have no idea why the filter isn't applying. If anybody knows that might be the answer to this problem, it would be greatly appreciated. Thanks.