Combobox Data

Combobox Data

Postby Rick Lipkin » Fri Sep 18, 2015 2:12 pm

To All

I am migrating an application and I have a field called Status which I am using in a combobox .. However I ran across a problem .. what happens if the data in the table ( in this case = "Dispute" ) is not found in the array aStatus ? .. apparently cStatus is not found even though the data for cStatus = "Dispute" .. but the value that shows in the combobox is blank ..

Is there a way to over-ride that behavior if cStatus is not found in aStatus so that if cStatus is not found, at least cStatus will be visible in the combobox field?

Thanks
Rick Lipkin

Code: Select all  Expand view

Local oStatus,cStatus,aStatus

aStatus := {}
aadd( aStatus, "All")
aadd( aStatus, "Active" )


cStatus := a->Status  // "Dispute"

REDEFINE COMBOBOX oStatus  var cStatus   ID 148 of oInvt  ;
             ITEMS aStatus when cMode <> "V"
   oStatus:SetFont( oFontB )
   oStatus:lIncSearch = .T.

 
User avatar
Rick Lipkin
 
Posts: 2641
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Re: Combobox Data

Postby James Bott » Fri Sep 18, 2015 2:31 pm

Rick,

Is sounds like you have a referential integrity issue. Can't you just add "Dispute" to the array, or are there lots more possible items that aren't in the list?

If so, you could create a UNIQUE index on the field and use that data to load the array. But I do wonder how data that was not allowed got into the field?

James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: Combobox Data

Postby Rick Lipkin » Fri Sep 18, 2015 2:45 pm

James

I am in the process of converting some old Excel data and this data is a mess. As I import the data I am building the lookup tables as I go, so technically, the imported data will be in the lookup tables I create as I loop thru excel.

My question is two fold .. what happens if someone deletes a record in one of the look up tables and as I build my array for the combobox during data entry, that value is missing from the array so when I edit or view the main table that has the value .. since that field value was not found in the array . the combobox value is blank.

If there is no other way around this, I will prob abandon the combobox and just use a field with a look up table.

Rick Lipkin
User avatar
Rick Lipkin
 
Posts: 2641
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Re: Combobox Data

Postby James Bott » Fri Sep 18, 2015 4:23 pm

Rick,

My question is two fold .. what happens if someone deletes a record in one of the look up tables and as I build my array for the combobox during data entry


I would question why would you allow anyone to do that? Shouldn't the table be built by you and maintained by you, and maybe an admin? Actually, for integrity you can't allow any item to be deleted from the table once it has been used.

...that value is missing from the array so when I edit or view the main table that has the value .. since that field value was not found in the array . the combobox value is blank.


There is a method add( cItem, nAt) for the combobox, so technically you could add it on the fly. But, I still maintain that you should build the lookup table and never delete anything from it. Anything else is going to create a nightmare.

I also note that you should always have a blank entry in the lookup table. Consider what will happen if you don't. During data entry of a new record, what if a user doesn't know or have the answer for that field. Since it is a constrained field, the user is forced to select something, so instead of getting no data, you get incorrect data. An empty field is easy to find later, but incorrect data is just about impossible to find.

There is a similar problem with radio buttons--no blank option.

Regards,
James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: Combobox Data

Postby Rick Lipkin » Fri Sep 18, 2015 4:44 pm

James

If I keep the comboboxes .. I will definitely only allow deletes on the look up data .. only if I check to see if the value exists in the main table .. I haven't made up my mind yet .. I like the incremental search feature of the combobox, but I use Get\Action to fire off a data validation browse .. that way I have my regular get instead of the combobox value .. Don;t know what I am going to do yet.

Rick Lipkin
User avatar
Rick Lipkin
 
Posts: 2641
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Re: Combobox Data

Postby James Bott » Fri Sep 18, 2015 5:09 pm

Rick,

If I keep the comboboxes .. I will definitely only allow deletes on the look up data .. only if I check to see if the value exists in the main table ..


I'm not clear what you are saying. It sounds like you said just the opposite of what I would expect--only allow deletes on the lookup data if the value DOES NOT exist in the main table. Is that what you meant?

Generally I would only allow additions to the lookup table, never deletions. Then I don't think I have ever dealt with the situation where we needed to remove an option for all future records.

Is the purpose of the combobox to limit users to specific choices, or are these just suggestions? Maybe if you provided more details, I could offer more relevant suggestions.

James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: Combobox Data

Postby Rick Lipkin » Fri Sep 18, 2015 5:13 pm

James

I am multi-tasking .. If I allow deletes on the look up tables .. I will first look to the main data to see if that value exists .. if it does .. I WILL NOT allow any deletes on the lookup data that makes up the Ccombobox array.

Sorry for the confusion

RIck Lipkin
User avatar
Rick Lipkin
 
Posts: 2641
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Re: Combobox Data

Postby James Bott » Fri Sep 18, 2015 5:23 pm

Rick,

Got it.

Multitasking--the life of every programmer. I think we are all prematurely wearing out our brains...

James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 92 guests