Filter Problem

PC User

Registered User.
Local time
Today, 10:17
Joined
Jul 28, 2002
Messages
193
I have command button on one form that opens a second form that I want information to be filtered by UserID. I've tried several ways to use filters, but I can't seem to get them to work. Below is my latest attempt to link the forms with a filter. The information displayed on the second form should be all the records associated with the user's UserID. This is not just one record, but are multiple records.

Code:
--------------------------------------------------------------------------------
Private Sub btnAdminCalendar_Click()
Dim strForm As String
Dim strLinkCriteria As String
strForm = "fdlgCalendar_Admin"
strLinkCriteria = "[UserID] = " & Forms!frmMainEntry.cboAdminCalendar.Column(0)
DoCmd.OpenForm strForm, , , strLinkCriteria
End Sub
--------------------------------------------------------------------------------

Help would be appreciated.
Thanks,
PC
 
I also tried another approach, but I can't get it to work either.
Code:
--------------------------------------------------------------------------------
Private Sub btnAdminCalendar_Click()
Dim strForm As String, strSQL As String
Dim strFilter As String, strWhere As String
strForm = "fdlgCalendar_Admin"
strSQL = "SELECT tsubPermissionList.UserID, * " & _
"FROM tsubPermissionList INNER JOIN tblMainData ON tsubPermissionList.FullName = " & _
"tblMainData.ResponsibleParty" & _
"WHERE (((tsubPermissionList.UserID)=Forms!frmMainEntry.cboAdminCalendar.Column(0)))"
strFilter = strSQL
DoCmd.OpenForm strForm, acNormal,, strFilter
Forms(strForm).Form.Filter = strFilter
Forms(strForm).Form.FilterOn = True
Forms(strForm).Form.Requery
End Sub
--------------------------------------------------------------------------------
Help would be appreciated.
Thanks,
PC
 
I'm still struggling with this filter issue. This is my latest try. I'm missing something, because I can't get this to work. I hope someone has time to help me.
====================================
Private Sub btnUsersProjectCalendar_Click()
On Error GoTo Whoops

Dim strForm As String
Dim strFilter As String
Dim strSelect As String, strFrom As String, strJoin As String
Dim strWhere As String
strForm = "fdlgCalendar_Admin"

strSelect = "SELECT tblMainData.* "
strFrom = "FROM tblMainData "
strJoin = "INNER JOIN tsubPermissionList ON tblMainData.ResponsibleParty = tsubPermissionList.FullName "
strWhere = "WHERE(((tsubPermissionList.UserID) = [Forms]![frmMainEntry].[cboAdminCalendar].Column(0))) "
strFilter = strSelect & strFrom & strJoin
DoCmd.OpenForm strForm, acNormal, strFilter, strWhere, acFormPropertySettings, acNormal

Forms(strForm).FilterOn = True

OffRamp:
Exit Sub
Whoops:
MsgBox "Error #" & Err & ": " & Err.Description
Resume OffRamp

End Sub
====================================
Thanks,
PC
 
Last edited:

Users who are viewing this thread

Back
Top Bottom