Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Filter propert on form uses form textboxes nopt table field names

Posted on 2011-03-24
2
Medium Priority
?
236 Views
Last Modified: 2012-05-11
I have two database systems.

In one when the user applies a filter to a form the filter property on the form is set using the forms control names
e.g. ([frmContacts].[contactTelephoneNumber] Like "*N/A*")

In the other the filter property is set using the table names
e.g.([tblClient].[CL_Name] Like "*Pa*")

Both forms are based on a query of one table - one the contact table one  the client. table.
Remember both filters are set from the ribbon - none of my code.

I need the filters to use the table names (so I can use the me.filter string in an sql command to append to a table e.g.

DoCmd.RunSQL "Insert Into ContactsForMailMerge Select * From tblClient Where " & Screen.ActiveForm.Filter

This works filne when the filter uses the table names but obviously not when it uses the form names.


Why are the two forms using different syntax for the same property?
By the way if I copy the one using form names to the other database - it still uses form names.


Thanks
Lou
0
Comment
Question by:Louverril
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 24

Accepted Solution

by:
Bitsqueezer earned 2000 total points
ID: 35213147
Hi,

I think it depends on the RecordSource you used in the form. If the field you filters is 1:1 a table field then the filter will use the table field. If the field is a calculated field in the query (not in the form, that cannot be filtered) like "SELECT [Field1] & [Field2] AS Field3..." then there is no field of the table which can be used and so Access uses the form field instead. Of course a field like this can also not be used to insert a value with an INSERT command - because there is no "Field3" in the table to SELECT. You must use the same method to select the data from the underlying tables like used in the RecordSource. You should be able to use "SELECT [Forms]![frmContacts].[contactTelephoneNumber]..." but only if the form is loaded.
But as you can see in the filter expression, there is no "Forms!" prefix and so it will be interpreted as query parameter which must be entered.
If you want to use your INSERT command you must make sure that all fields of the form are based directly on table fields or you must write a text parser which analyzes the filter string and "repairs" it. Not an easy job as there are a lot of possible filter variants.

Cheers,

Christian
0
 

Author Comment

by:Louverril
ID: 35244244
Thanks for that - will check it out in the next couple of days - O got sidetracked with something else but tomorrow this is back as priority 1.

I think I will have to use me.recordsetclone and create a table.

thanks Lou

0

Featured Post

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
AutoNumbers should increment automatically, without duplicates.  But sometimes something goes wrong, and the next AutoNumber value is a duplicate.  This article shows how to recover from this problem.
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question