UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
 
   Reply to this topicStart new topic
> Opening A Filtered Form, Access 2003    
 
   
richl
post Jan 13 2018, 07:49 AM
Post#1



Posts: 181
Joined: 2-August 06
From: Yorks




Im using a command button to open a form from a form with the link critieria below:


stLinkCriteria = "[NOTE_PROPERTY_FK]=" & Me![PROPERTY_PK]

Works fine, but is it possible to add a filter to the end of that, for example:



stLinkCriteria = "[NOTE_PROPERTY_FK]=" & Me![PROPERTY_PK] & Me![NOTE_MAINTENANCE] = True


so the forms opens only showing records where NOTE_MAINTENANCE = true


Im opening from a subform if that makes any difference.

Thanks for any help.

Go to the top of the page
 
JonSmith
post Jan 13 2018, 07:59 AM
Post#2



Posts: 3,441
Joined: 19-October 10



Hi, the issue is with how VBA reads you building that string. Sinec the Note_Maintenance part isn't in quotations it takes the value of it aswell as the & being to join strings, not to be the AND part of a string.
If you put a line break after it or add a watch for it you should see the value as something like this

CODE
"[NOTE_PROPERTY_FK]=1True=True"


This is more like what you should need, pay attention to the quote marks. I assume Note_Maintenance is a field in your subform?

CODE
stLinkCriteria = "[NOTE_PROPERTY_FK]=" & Me![PROPERTY_PK] & " AND [NOTE_MAINTENANCE] = True"
Go to the top of the page
 
richl
post Jan 13 2018, 09:25 AM
Post#3



Posts: 181
Joined: 2-August 06
From: Yorks


Thanks for the reply.

NOTE_MAINTENANCE is not on the subform but on the form which Im opening, and Im trying to get the command button on the subform to filter the 2nd form when opening.

Hope that makes sense.

Go to the top of the page
 


Custom Search
RSSSearch   Top   Lo-Fi    23rd June 2018 - 06:36 AM