Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with Dropdown list selecting past 12 item 1

Status
Not open for further replies.

ggrewe

IS-IT--Management
Jul 10, 2001
169
US
Hi all, I am designing a form with a combobox set up as a dropdown list. The control source is a table with over 90 rows. The dropdown list displays all the rows appropriately, but when I select an item higher than 12 in the list, it deactivates the list and the lostfocus method does not fire. BoundColumn is 1 and BoundTo is True. I am running VFP6.0, SP4. Any help is greatly appreciated.

Greg Grewe
greg@grewe.d2g.com
 
Hi Greg,

Is there any of your own code which fires when an item is selected?

Jim
 
Jim;

Here is the code in the LostFocus method. Thanks for your help.

Greg

WITH THISFORM

STORE THIS.Value TO lnTable_id
lnAttendee_id = .txtAttendee_id.value
UPDATE "tblTable_Assignments" SET tblTable_Assignments.Table_id = lnTable_id WHERE tblTable_Assignments.attendee_id = lnAttendee_id
SELECT "tblTable_Assignments"
TABLEUPDATE(.T.)
=Update_Table_assignments("attendee_table")
TABLEUPDATE(.T.)

ENDWITH
 
Am wondering why you think the LostFocus event should fire when you select an item. That isn't the default behavior.

Jim
 
Jim,

Only using LostFocus because I could not find a method or event to fire after selection. Also since I am updating a coupple of tables, I did not want to actualy update the tables until after they made their selection and moved on to the next field.

Greg
 
Greg,

Sorry, but am leaving for vacation(!) soon and probably won't be able to see this problem through. A couple of thoughts:

1. Does the problem occur if you select an item higher than 12 on the very 1st selection? If so, it eliminates your LostFocus routine as the culprit.

2. Are the tables related, and if so are you possibly messing-up the relationship (creating orphaned records, maybe) in your update code?

Jim
 
Personally, I use the InteractiveChange event to execute code when an item gets selected. This will fire as soon as an item is clicked from the list. This will NOT fire, however, if you pull the list down and select the item that was selected already.

Using the LostFocus event is fine if you want your code happening after you TAB out of the combobox.
 
Jim,

Thanks for answer back, yes the problem happens on the first selection as well as any subsequent selections. The tables are not related, I am updating another table with the results of the selection in this list.

chpicker,

I am only really using the LostFocus event becuase I do not really want to run the table updates unti lafter they are sure they want this selection.
 
This may sound odd, but have you tried inserting a quick debug box into your LostFocus event? Something like this:
Code:
=MessageBox("The LostFocus event has fired!")
This will tell you for sure if the event is firing. Many times I've been so sure that FoxPro was messing up and not firing my events...but putting this in showed me that yes, indeed, the events were firing...but my code was missing something that made it LOOK like it was being skipped.
 
Actually, I have tried this exact thing. I know that the event is firing, except whenever I pick a value over the 12th item on the list.
 
Looking at your initial post again, I wonder what you mean here:

"when I select an item higher than 12 in the list, it deactivates the list"...

What do you mean it deactivates the list? Are you saying that it becomes disabled, or that it simply loses focus without firing the LostFocus event?

This is mainly a workaround, but try moving your code from LostFocus to Valid. The difference between them is that Valid occurs as the control is ABOUT to lose focus, while LostFocus occurs after the control has already lost it. (The other difference is you cannot execute a SetFocus method from within a Valid event, but you are not using one in your code so this should work fine.)
 
The control becomes disabled and will not allow you to select it again and it does not fire the code, regardless of whether or not it is in LostFocus, IntervactiveChange or Valid. I have come up with a workaround. I am now setting the value a text filed to the value of the list box and storing that value to my tables. I have shrunk the list box down so that all you see is the dropdown arrow and removed the controlsource value.

I know this is not right, but it is working. I will mess with more when I have the time. This has been driving me crazy for the past three days.

Thanks for all your help. If you have any other ideas, please let me know!

Greg
 
Hmm...

It sounds to me like code from somewhere ELSE is disabling the control. Do you have code in ANY other control that sets the .Enabled property of your combobox to .F.? Such as the GotFocus or When event of a text box?
 
Nope, but I have the answer now. The data source of the drop downlist was table "A", with about 30 rows. The controlsource was table "B", which are related on another field. Since table "B" does not have more than 12 rows in it, it could not find a match and apparently that disables the control. When I added two more rows, then problem did not happen until after I selected the 14th item in the list.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top