Ask Your Question
0

filter from control value

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

EasyTrieve gravatar image

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

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 close merge delete

1 Answer

Sort by » oldest newest most voted
1

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

Ratslinger gravatar image

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

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'
    oForm.Reload()

Sample: C:\fakepath\SelectCompanyByFilter3.odb

edit flag offensive delete link more

Comments

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 +0100 )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 +0100 )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 +0100 )edit
Login/Signup to Answer

Question Tools

2 followers

Stats

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

Seen: 101 times

Last updated: Mar 24 '17