a few quick ?'s (1 Viewer)

RpbertS

Registered User.
Local time
Today, 18:42
Joined
Feb 14, 2000
Messages
93
okay heres my code:
Private Sub Form_Load()
DoCmd.GoToRecord , , acNewRec
If IsFormOpen("associate/project") = True Then
DoCmd.ApplyFilter , "LastName = Forms![Associate/Project]![txtlast]"
End If
On Error GoTo Err_Form_Load
DoCmd.ApplyFilter , "LastName = Forms![Associate/Project]![txtlast]"
DoCmd.Restore
Exit_Form_Load:
Exit Sub
Err_Form_Load:
MsgBox Err.Description
Resume Exit_Form_Load
End Sub
okay what I want to accomplish is this on load if the function returns true then it runs the filter, if it returns false it should do one of two things not run the filter or remove filters from that form. the last part ahs got me stuck.
any help would be appreciated thank you,
Rpb
 

ingvar68

Registered User.
Local time
Today, 18:42
Joined
Jun 22, 2000
Messages
21
if i understand you problem may be the VBA helps you

Private Sub Form_Load()
DoCmd.GoToRecord , , acNewRec
If IsFormOpen("associate/project") = True Then
me.Filter = "[LastName] like '*" & Forms![Associate/Project]![txtlast] & "*'"
me.FilterOn=True
else
me.FilterOn=False
end if
End Sub

glad to answer
 

RpbertS

Registered User.
Local time
Today, 18:42
Joined
Feb 14, 2000
Messages
93
Hi thanks for hte reply but its still not working correctly, it will not apply the filter heres the code now:
---------
Private Sub Form_Load()
If IsFormOpen("associate/project") = True Then
Me.Filter = "[LastName] like '*" & Forms![Associate/Project]![txtlast] & "*'"
Me.FilterOn = True
MsgBox ("im here")
Else
Me.FilterOn = False
End If
End Sub
--------
I stuck the message box to test if it was returning a true value but its not, so then I created a new form with just a cmd button to test the function and it worked fine,..so i'm not sure whats going on,

any more help would be great thanks.
Rpb
 

MHM

Registered User.
Local time
Today, 18:42
Joined
Mar 15, 2000
Messages
101
What about the IsFormOpen-function?

Probably this doesn't work properly - otherwise it'll put you at least to that MsgBox!
 

Users who are viewing this thread

Top Bottom