I have a form which contains a field that collects the MSysObjects list of queries within the system.
Also on this form there is a button that is told to apply the query chosen by the user to a certain second form, however I cant seem to tell the button to select the object.
Currently I have:
SELECT MSysObjects.Name FROM MSysObjects WHERE (((MSysObjects.Name)=Me![Choose Filter]))
Anyone help please !
It depends how you're trying to use it.... but I'd suspect that if you're
trying to use it as a record source then it doesn't look like you're
building it as a string correctly.
It would need to be along the lines of
Forms!FormName.RecordSource="SELECT MSysObjects.Name FROM MSysObjects WHERE
(((MSysObjects.Name)='"+Me![Choose Filter]+"'))"
> I have a form which contains a field that collects the MSysObjects list of queries within the system.
>
> Also on this form there is a button that is told to apply the query chosen by the user to a certain second form, however I cant seem to tell the button
to select the object.
> Currently I have:
>
> SELECT MSysObjects.Name FROM MSysObjects WHERE (((MSysObjects.Name)=Me![Choose Filter]))
>
> Anyone help please !
Brendan Reynolds - 20 Jan 2005 23:32 GMT
Another possibility is that the use of "Name" as a field name in MSysObjects
may be causing a problem. It might be worth putting square brackets around
it ...
="SELECT MSysObjects.[Name] FROM MSysObjects WHERE
(((MSysObjects.[Name])='"+Me![Choose Filter]+"'))"

Signature
Brendan Reynolds (MVP)
http://brenreyn.blogspot.com
The spammers and script-kiddies have succeeded in making it impossible for
me to use a real e-mail address in public newsgroups. E-mail replies to
this post will be deleted without being read. Any e-mail claiming to be
from brenreyn at indigo dot ie that is not digitally signed by me with a
GlobalSign digital certificate is a forgery and should be deleted without
being read. Follow-up questions should in general be posted to the
newsgroup, but if you have a good reason to send me e-mail, you'll find
a useable e-mail address at the URL above.
> It depends how you're trying to use it.... but I'd suspect that if you're
> trying to use it as a record source then it doesn't look like you're
[quoted text clipped - 22 lines]
>>
>> Anyone help please !
Simon Radford - 21 Jan 2005 14:43 GMT
To date I have set the following as an option instead of a button as I cant seem to find
and answer to the button issue.
I have set this as an after update event on the combo box itself
to set the focus on a second form, apply the filter chosen in combo box of the first form
then set the focus back to the original first form.
This does not apply the MYsysObects filter chosen from the combo box either, but I think
I am getting closer to a solution.
Private Sub Choose_Filter_AfterUpdate()
Forms![Contacts].SetFocus
DoCmd.ApplyFilter " & [Search Filter].[Choose Filter] & " '"
Forms![Search Filter].SetFocus
End Sub
Rob Oldfield - 21 Jan 2005 20:09 GMT
The string that you need to feed to a filter would look something like...
[Name]='YourQuery'
...so it doesn't look to me that you're quite there yet.
My advice would be to first get the code working with the name of a query
hard coded into the ApplyFilter command. That would look like...
DoCmd.ApplyFilter , "[Name]='YourQuery'"
(Note that first comma, that's there on purpose. The first argument for
ApplyFilter allows you to feed it the name of a filter - which I don't think
is what you're after.)
Once you have that working, then you can start trying to integrate the
Choose Filter control...
dim crit as string
crit="[Name]='"+me.[Choose Filter]+"'"
'add a debug.print crit here maybe for debugging purposes
docmd.applyfilter ,crit
> To date I have set the following as an option instead of a button as I cant seem to find
> and answer to the button issue.
[quoted text clipped - 11 lines]
> Forms![Search Filter].SetFocus
> End Sub