Selecting MSysObjects

  • Thread starter Simon Radford via AccessMonster.com
  • Start date
S

Simon Radford via AccessMonster.com

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 !
 
R

Rob Oldfield

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]+"'))"



Simon Radford via AccessMonster.com said:
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]))
 
B

Brendan Reynolds

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]+"'))"

--
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.


Rob Oldfield said:
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]+"'))"



Simon Radford via AccessMonster.com said:
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 !
 
S

Simon Radford via AccessMonster.com

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
 
R

Rob Oldfield

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
 

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