473,382 Members | 1,368 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Pass Form Name To Do Filter

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
1 2488
ADezii
8,834 Expert 8TB
@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

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

Similar topics

3
by: Jason | last post by:
I am trying to filter records in a primary form based on records in related tables. The data in the related tables is being displayed in the primary form through subforms. To be more specific, I...
2
by: Iain Miller | last post by:
Now this shouldn't be hard but I've been struggling on the best way as to how to do this one for a day or 3 so I thought I'd ask the assembled company..... I'm writing an application that tracks...
0
by: CSDunn | last post by:
Hello, I have a problem with field filtering between an Access 2000 Project form (the application is called CELDT), and the report that shows the results of the filter. Both the form and the...
4
by: John Boy | last post by:
Hi, Can anyone help. This is really doing my nut in. 3 years ASP exp. and now doing .DOT which is a step in the wrong direction. Basically I am left with the code of a guy who has left. When I...
8
by: fonzie | last post by:
I have an edit button on my form that changes the recordsettype of the form, causing the form to requery. If I have a filter applied on the form before I hit the edit button, it is not applied to...
3
by: emgallagher | last post by:
I have a form which lists studies. People can filter the form based on details about the study, such as the study type. Currently users filter via the right click method. I would like to be...
8
by: jesmi | last post by:
my code is: addRecord.cfm <cfinclude template="head.cfm"> <p> <table width="100%" border="0" align="center" cellpadding="2" cellspacing="0"> <tr> <td> <div align="center">
3
by: bdbeames | last post by:
Ok I have a form validation problem that I need one of you javascript ninja s to help me with. The following is a form with the javascript that I have used for the last year or two to validate. ...
3
by: franc sutherland | last post by:
Hello, I have a report which I filter using the me.filter command in the OnOpen event. Me.Filter = "OrderID=" & Forms!variable_form_name! Me.FilterOn = True I want to be able to open that...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.