On 12/9/2010 7:06 PM, Jeff Johnson wrote:
> I have a combobox where I want the control source value to be displayed
> in the combobox. If the user wants to change it they can select an item
> from the drop down. I have never really done this, but what I want to
> do is to be able to use it like a text box and only use the list feature
> if they want to.
>
> For example, it has "Jeff" in the table and I can type in "Jeffo" and it
> will save it. Neither Jeff nor Jeffo are in the drop down list which
> comes from another table.
Sounds like a regular combo dropdown. Here's code in the Valid event of
one of my combo dropdown classes:
IF EMPTY(This.Value) AND !EMPTY(this.DisplayValue) THEN
LOCAL lcNewType as String, lnID as Integer, lnOldArea as Integer,
lcIDDesc as String
lcNewType = ALLTRIM(this.DisplayValue)
* The user typed in a new item that isn't on file; see if it should
be added.
IF MESSAGEBOX("This " + this.cIDDesc + " is not currently on file.
Would you like to add " + lcNewType + " to the database? Note: Only "
+ this.cIDDesc + IIF(LOWER(RIGHT(this.cIDDesc,1))="s","es","s") + " that
are in the database can be used.",4+32+0,"Add new " + this.cIDDesc + "
to database?") = 6 THEN
lnOldArea = SELECT()
lcIDDesc = PROPER(this.cIDDesc)
DO CASE
CASE lcIDDesc = "Type"
lnID =
thisform.oBiz.AddType(this.cIDType,lcNewType) && adds new
type and returns unique id for it
thisform.GetTypes() && mjb 08-29-09 was
thisform.oBiz.GetTypes(this.cIDType) && will call a REQUERY to get the
new resulting set (including new record)
this.Populate()
CASE lcIDDesc = "Class"
lnID =
thisform.oBiz.AddClass(this.cIDType,lcNewType) && adds new
class and returns unique id for it
thisform.GetClasses() && mjb 08-29-09 was
thisform.oBiz.GetClasses(this.cIDType) && will call a REQUERY to get the
new resulting set (including new record)
this.Populate()
OTHERWISE
MESSAGEBOX("Problem with object. Contact your
vendor for
assistance.",16,"Unknown object type (" + lcIDDesc + ")")
ENDCASE
this.Value = lcNewType
this.DisplayValue = lcNewType
SELECT (lnOldArea) && restore previous work area
this.Refresh()
ENDIF
ENDIF
--
Mike Babcock, MCP
MB Software Solutions, LLC
President, Chief Software Architect
http://mbsoftwaresolutions.com
http://fabmate.com
http://twitter.com/mbabcock16
_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/profox
OT-free version of this list: http://leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message:
http://leafe.com/archives/byMID/profox/[email protected]
** All postings, unless explicitly stated otherwise, are the opinions of the
author, and do not constitute legal or medical advice. This statement is added
to the messages for those lawyers who are too stupid to see the obvious.