TOPIC: How do I use the AutoChoose Control?
#1175
How do I use the AutoChoose Control? 2 Years, 3 Months ago
First of all I love the AutoChoose Control it seems to fit user flow better. I'm having trouble hooking up AutoChoose to the database

I can get this to work

Field_string
{
Prompt: "Description"
Control: (AutoChoose #('Hello', 'Goodbye'))
Format: (Text width: 30)
}

I can't get this to work it says it can't find a filter method which to me means its not getting the right type/object somewhere along the line. The Rule_getdescription() function returns an object full of strings.

Field_string
{
Prompt: "Description"
// Not working
Control: (AutoChoose list: Rule_getdescription())
Format: (Text width: 30)
}

Any idea what I'm doing wrong?
 
 
#1176
Re:How do I use the AutoChoose Control? 2 Years, 3 Months ago
Try removing the '()' so it's:

Control: (AutoChoose list: Rule_getdescription)

I'll try to explain. This is a constant. Which means it can't contain any function calls. What you're specifying is the name of the function (a string). This would be exactly the same:

Control: (AutoChoose list: "Rule_getdescription" )

The parenthesis actually become another argument. Try:

Inspect(#(AutoChoose list: Rule_getdescription()))

Note: This doesn't actually require a "rule". You could call it simply "Getdescription". (Unless you use it as a rule elsewhere.)

Hope that helps.
 
 
Last Edit: 2008/04/30 17:40 By andrew.
 
andrew
 
#1177
Re:How do I use the AutoChoose Control? 2 Years, 3 Months ago
Your post was very helpful and pointed me in the right direction. I did try just my function name on the list parameter without success. Looking at the AutoChoose code it looks like it just wants an array.
So I then tried the following to make sure my function worked
Window([#AutoChoose, Getdescription()])

This worked which gave me an idea

AutoChooseFromDatabaseControl = AutoChooseControl
{
New(query = "",listcolumn = "", width = 40, status = "", readonly = false, mandatory = false, allowOther = true)
{
super(QueryList(query ,listcolumn), width, status , readonly,mandatory, allowOther)
}
}

So when I do my field declaration I just do

Field_string
{
Prompt: "Description"
Control: (AutoChooseFromDatabase query: "tables" listcolumn: "tablename")
}

Access works like this with combo boxes

What do you think?
 
 
#1178
Re:How do I use the AutoChoose Control? 2 Years, 3 Months ago
Sorry, I was looking at the current source code and it has been improved since the last release.

Your approach is good - thanks for sharing it.
 
 
andrew