DoCmd Apply Filter

  • Thread starter cutepaloma405 via AccessMonster.com
  • Start date
C

cutepaloma405 via AccessMonster.com

I have two forms: frmStudent and frmCourse. What I want to do is link
frmStudent and frmCourse through the EmployeeID control to get a filter of
each student's courses. Problem: EmployeeID is a string. What I am doing
wrong with the below cited?

stLinkCriteria = "[EmployeeID] = " & Me![EmployeeID]
DoCmd.OpenForm stDocName, , , , acNormal, , stLinkCriteria
DoCmd.ApplyFilter , "EmployeeID="", & EmployeeID & """
 
J

johnlute

I have two forms: frmStudent and frmCourse.  What I want to do is link
frmStudent and frmCourse through the EmployeeID control to get a filter of
each student's courses.  Problem:  EmployeeID is a string.  What I am doing
wrong with the below cited?

stLinkCriteria = "[EmployeeID] = " & Me![EmployeeID]
DoCmd.OpenForm stDocName, , , , acNormal, , stLinkCriteria
DoCmd.ApplyFilter , "EmployeeID="", & EmployeeID & """

What is currently in your frmStudent's Link Master and Link Child
fields...?
 
D

Dorian

You need string delimiters (apostrophes) around the value:

stLinkCriteria = "[EmployeeID] = '" & Me![EmployeeID] & "'"

I'm not sure why you are using link criteria and a filter, you only need one
or the other.

-- Dorian
"Give someone a fish and they eat for a day; teach someone to fish and they
eat for a lifetime".
 
A

AccessVandal via AccessMonster.com

Use the FilterName or WhereCondition instead of the OpenArgs. The below shows
the WhereCondition. If EmployeeID is Numeric, if not you need the quotes.

stLinkCriteria = "[EmployeeID] = " & Me![EmployeeID]
DoCmd.OpenForm stDocName, , ,stLinkCriteria

Don't need the ApplyFilter as the Form may not be in the correct focus.
I have two forms: frmStudent and frmCourse. What I want to do is link
frmStudent and frmCourse through the EmployeeID control to get a filter of
each student's courses. Problem: EmployeeID is a string. What I am doing
wrong with the below cited?

stLinkCriteria = "[EmployeeID] = " & Me![EmployeeID]
DoCmd.OpenForm stDocName, , , , acNormal, , stLinkCriteria
DoCmd.ApplyFilter , "EmployeeID="", & EmployeeID & """
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top