We will be migrating from Ask to Discourse on the first week of August, read the details here

Ask Your Question

filter from control value [closed]

asked 2017-03-23 20:12:03 +0200

EasyTrieve gravatar image

updated 2017-03-23 20:15:40 +0200

In Base is there a way to set a form's filter property to use the value of another text or numeric control?

For example below, I want a control named FromLookup to be the value of ID that I'm filtering for:

image description

In this case FromLookup would evaluate to a value, like 11 for example. The way it is it tries to run test.ID = FromLookup which fails because FromLookup doesn't exist as a field. I can put in test.ID = 11 and that works. But what I fail to see is how to use another value here to get inserted into the SQL, like something named FromLookup that evaluates to 11.

I would like my main form to be filtered not by a subform, but rather by the current value of a list box.

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by Alex Kemp
close date 2020-09-28 13:41:54.205287

1 Answer

Sort by » oldest newest most voted

answered 2017-03-23 20:54:46 +0200

Ratslinger gravatar image

updated 2017-03-24 02:00:57 +0200

EasyTrieve gravatar image

You need to use a macro.

'Get value from control'
    myData = FromLookup.Data 'or Value or whatever'
'Create filter'
    myFilter = "(`test`.`ID` = " & myData & ")"
'Insert filter in form properties'
    oForm.Filter = myFilter
'Reload form'

Sample: C:\fakepath\SelectCompanyByFilter3.odb

edit flag offensive delete link more


Thanks! Don't know why I had my head stuck in thinking that the property value could be evaluated, when it's just a simple string.

EasyTrieve gravatar imageEasyTrieve ( 2017-03-23 22:17:09 +0200 )edit

Just curious. Why do you put a tick on the end of your remarks? BTW, it works great.

EasyTrieve gravatar imageEasyTrieve ( 2017-03-23 22:39:16 +0200 )edit

It stops the comment coloring (green) from carrying on to the next code line. Just a formatting situation.

Ratslinger gravatar imageRatslinger ( 2017-03-23 22:51:37 +0200 )edit

Question Tools



Asked: 2017-03-23 20:12:03 +0200

Seen: 505 times

Last updated: Mar 24 '17