Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Listbox won't reset when record changes?
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00456527
Message ID:
00456541
Views:
22
Hi Steve,

May be it's not a direct anser on your question, but there are few things, which caught my attention. I'll place my comments in bold.

>Here is my code: (The listbox stays the same as the previous record's listbox) I haven't figure this one out for a couple of hours. Any clues? TIA!
>
>My listbox is named lstAEDDisp_list on THISFORM.
>
>SELECT aed_hist
>SET ORDER TO date
>GO TOP && Go to first record
>scatter memvar memo
>THISFORM.lstAEDDisp_list.DisplayValue = m.aedid
>
>loRef = THISFORM
>FOR ii = 1 TO loRef.ControlCount
>	DO CASE
>		CASE loRef.Controls(ii).BaseClass = "Listbox"
>			loRef.Controls(ii).DisplayValue = ""
>			loRef.Controls(ii).Value = ""
<b>******* Why do you need this loop and case statement? ******
   ***** If you want to reset DisplayBalue of all listboxes to nothing, you can use SetAll (see Help on SetAll). I would comment this block of code. </b>   

>	ENDCASE
>NEXT
>
>SEEKID = ALLT(m.incident)+ALLT(m.patnum)+ALLT(m.patqty)
<b>** Another strange code: do you have alltrim in your index expression?
You should NEVER use alltrim as part of index expression (see another quite recent discussion on similar topic)</b>

>SELECT master
>SET ORDER TO TAG incident
>SEEK SEEKID <b> && Here you can change this block of code and use seek function instead</b>
>IF NOT FOUND()
>	MESSAGEBOX("Master record NOT FOUND.",0+64,"AED History")
>ELSE
>	savmaster = recno()
>ENDIF
>IF SEEKID != savseekid <b>&& What is SavSeekID</b>
        <b> Another important observation - you should always declare your variables as local (if, of course, you don't need them as private, otherwise your variables would be private by default and you may accidentally use the same name in calling procedure - we recently found this error in my colleague's code</b>  
>	SELECT aed_hist
>	SET ORDER TO TAG incident
>	SCAN FOR ALLT(aed_hist.incident)+ALLT(aed_hist.patnum)+ALLT(aed_hist.patqty) = SEEKID <b>&& Once again - don't use alltrim here</b>
>		THISFORM.lstAEDDisp_list.AddItem(aed_hist.aedid)
>	ENDSCAN
>	WITH THISFORM <b>&& Here you can use with thisform.lstAEDDisp</b>
>		.lstAEDDisp_list.ListIndex = 1
>		.lstAEDDisp_list.Requery
>		.lstAEDDisp_list.Refresh
>	ENDWITH
>	SEEK SEEKID
>	IF FOUND()
>		scatter memvar memo <b>&& May be you mean gather? </b>
>	ENDIF
>ENDIF
>
Sorry for not answering your question, but hopefully these observations will help you.

Best wishes and enjoy your Holidays!
If it's not broken, fix it until it is.


My Blog
Previous
Reply
Map
View

Click here to load this message in the networking platform