By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,480 Members | 1,676 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,480 IT Pros & Developers. It's quick & easy.

Pass Form Name To Do Filter

P: 68
HI,

I use the below code to filter records of the courses sub form

Expand|Select|Wrap|Line Numbers
  1. [Forms]![courses].Filter = "Courses.[Course Type] like '" & TypeofCourses & "'" & " and courses.[Course Title] like '" & CourseTitle & "'"
  2. [Forms]![courses].FilterOn = True
  3.  
I works fine with me, however when i wanted to used a varialbe instead of using the name of the form (courses)
i got stumped by the error 2450- MS Access cant find the form frm referred to in a macro expression or visual basic code


Expand|Select|Wrap|Line Numbers
  1. Dim frm as string
  2.  
  3. frm="courses"
  4. [Forms]![courses].Filter = "Courses.[Course Type] like '" & TypeofCourses & "'" & " and courses.[Course Title] like '" & CourseTitle & "'"
  5. [Forms]![courses].FilterOn = True
Does anyone have any idea?

thx in advance
Aug 1 '09 #1
Share this Question
Share on Google+
1 Reply


ADezii
Expert 5K+
P: 8,679
@ahd2008
There are several Methods that will work, this is but 1:
Expand|Select|Wrap|Line Numbers
  1. Dim frm As Form
  2.  
  3. Set frm = Forms![courses]
  4.  
  5. With frm
  6.   .Filter = "Courses.[Course Type] like '" & TypeofCourses & "'" & _
  7.             " and courses.[Course Title] like '" & CourseTitle & "'"
  8.   .FilterOn = True
  9. End With
Aug 1 '09 #2

Post your reply

Sign in to post your reply or Sign up for a free account.