Kamis, 18 Mei 2017

Re: [MS_AccessPros] Filter

 

John-
Sorry for my late reply. I fell asleep last night.

The source table is the

tblEmployeeMenu
EMID
EmployeeID
EMFormName

FilterID
FormType
tblFormType
FTID

FormType

e.g. Data in tblFormType
1    edit
2    read only
3    filter by ID

So in the tblEmployeeMenu, If FormType is 3, Employee(user) can open the form vie filter which matches the FilterID (e,g.CoachOperatorID) of the opening form, and the "EmployeeID" of the current user. The EmployeeID is behind the frmEmployeeMenu, and it opens all the time. 

Best Regards,
Kevin

Kevin Zhao


Kevin Zhao



发件人: John Viescas JohnV@msn.com [MS_Access_Professionals]
发送时间: 5月18日星期四 22:44
主题: Re: [MS_AccessPros] Filter
收件人: ms_access_professionals@yahoogroups.com


 

Kevin-


You answered one of my two questions.  The other is:


What is the Record Source of the form where the OpenForm is running?  If it has no Record Source, what controls are on the form, and what do they contain?  In other words, where are you getting EmployeeID to build a filter on CoachOperatorID?


John Viescas, Author

Effective SQL

SQL Queries for Mere Mortals 

Microsoft Access 2010 Inside Out

Microsoft Access 2007 Inside Out

Microsoft Access 2003 Inside Out

Building Microsoft Access Applications 

(Paris, France)





On May 18, 2017, at 4:31 PM, qing qing qingqinga@yahoo.com [MS_Access_Professionals] <MS_Access_Professionals@yahoogroups.com> wrote:




John-

The table souce is tblGroup. The form is frmGroupList.

tblGroup

GroupID

GroupName

Pax

CoachOperatorID

HotelOperatorID

...

Best Regards,

Kevin

Kevin Zhao





On Thu, May 18, 2017 at 9:50 PM +0800, "John Viescas JohnV@msn.com [MS_Access_Professionals]" <MS_Access_Professionals@yahoogroups.com> wrote:

Kevin-


What is the Record Source of the form you're trying to open?  (SQL if a query; field names if a table)  What is the Record Source of the form where this code is running?


John Viescas, Author

Effective SQL

SQL Queries for Mere Mortals 

Microsoft Access 2010 Inside Out

Microsoft Access 2007 Inside Out

Microsoft Access 2003 Inside Out

Building Microsoft Access Applications 

(Paris, France)





On May 18, 2017, at 2:21 PM, qing qing qingqinga@yahoo.com [MS_Access_Professionals] <MS_Access_Professionals@yahoogroups.com> wrote:




John-

I want the filter to work as:



The "CoachOperatorID" is stored under FilterID.

I am not able to figure out where and how many "" I need to get the effect of:

"CoachOperatorID=" & EmployeeID

Best Regards,

Kevin



Kevin Zhao





On Thu, May 18, 2017 at 7:50 PM +0800, "John Viescas JohnV@msn.com [MS_Access_Professionals]" <MS_Access_Professionals@yahoogroups.com> wrote:

Kevin-


Why do you want that?  That will still result in:


John Smith = 55


It will fail trying find a field named "John" or "Smith".  And even if you managed to get:


"John Smith" = 55


.. that will always be false and return no rows.


John Viescas, Author

Effective SQL

SQL Queries for Mere Mortals 

Microsoft Access 2010 Inside Out

Microsoft Access 2007 Inside Out

Microsoft Access 2003 Inside Out

Building Microsoft Access Applications 

(Paris, France)





On May 18, 2017, at 1:33 PM, qing qing qingqinga@yahoo.com [MS_Access_Professionals] <MS_Access_Professionals@yahoogroups.com> wrote:




John-

Yes, John Smith='55 is the result after debug.print. 

How to get this? "John Smith =" & 55

Best Regards,

Kevin


Kevin Zhao





On Thu, May 18, 2017 at 7:19 PM +0800, "qing qing qingqinga@yahoo.com [MS_Access_Professionals]" <MS_Access_Professionals@yahoogroups.com> wrote:


John-

This is a long story. Let me organize my word to make it short and easy to understand.

I have table named tblEmployMenu which stores the form names.

tblEmployeeMenu

EMID

EmployeeID

EMFormName

FilterID

FormType

tblFormType

FTID

FormType

e.g. Data in tblFormType

1    edit

2    read only

3    filter by ID

So in the tblEmployeeMenu, If FormType is 3, Employee(user) can open the form vie filter which matches the FilterID (e,g.CoachOperatorID) of the opening form, and the "EmployeeID" of the current user. The EmployeeID is behind the frmEmployeeMenu, and it opens all the time. 

Sorry for my poor English. I hope you may read me well enough by now. Thanks a lot for your patience.

Kevin Zhao





On Thu, May 18, 2017 at 6:37 PM +0800, "John Viescas JohnV@msn.com [MS_Access_Professionals]" <MS_Access_Professionals@yahoogroups.com> wrote:

 

Kevin-


If you look at strWhere (perhaps by doing a Debug.Print), it looks like:


'John Smith='55


That is not a valid predicate, so you'll either get an error or no rows.


Also, the arguments for OpenForm are:


FormNameViewFilterNameWhereConditionDataModeWindowModeOpenArgs


The fifth argument probably should be one of the data modes, like acFormEdit, not acFotm.  Are you trying to specify the View?  I prefer to use named arguments to avoid having to count commas, like this:


DoCmd.OpenForm "frmGroupList, WhereCondition:=strWhere, View:=acNormal, WindowMode:=acDialog


Notice that you don't have to specify the arguments in order, and by using the parameter names, it's easier to see what it going on.


What is in IDName and EmployeeID?  What is the name of the field you're trying to filter, and what does it contain?


John Viescas, Author

Effective SQL

SQL Queries for Mere Mortals 

Microsoft Access 2010 Inside Out

Microsoft Access 2007 Inside Out

Microsoft Access 2003 Inside Out

Building Microsoft Access Applications 

(Paris, France)





On May 18, 2017, at 12:08 PM, qing qing qingqinga@yahoo.com [MS_Access_Professionals] <MS_Access_Professionals@yahoogroups.com> wrote:




Dear All,


I would like to get the result of:


"SomeID=" & Me.EmployeeID as a filter


I have a text field IDName stores the name of the "SomeID" as title not as value.


So I wrote something like:


strWhere=""" & IDName & "="" & Me.EmployeeID


Then I apply it as this:


DoCmd.OpenForm "frmGroupList", , strWhere, , acFotm, acDialog


I didn't get the result I expected. Please help, Thanks.


Best Regards,


Kevin




Kevin Zhao






















__._,_.___

Posted by: qing qing <qingqinga@yahoo.com>
Reply via web post Reply to sender Reply to group Start a New Topic Messages in this topic (23)

Have you tried the highest rated email app?
With 4.5 stars in iTunes, the Yahoo Mail app is the highest rated email app on the market. What are you waiting for? Now you can access all your inboxes (Gmail, Outlook, AOL and more) in one place. Never delete an email again with 1000GB of free cloud storage.


.

__,_._,___

Tidak ada komentar:

Posting Komentar