Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Numeric key, combo, vfp3
Message
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
00056045
Message ID:
00056338
Views:
28
>>>The goal is to select items in table3 to associate with the current record in table1, and put a new record in table2 with the parentkeys for each. My first attempt to convert the keys to character in the SQL was to cheat: SELECT field1, field2, ALLTRIM(STR(keyfield)) AS keyfieldstr FROM table3 ... which the manual hints is not acceptable, since STR and ALLTRIM are not among the accepted functions, like COUNT() or whatever. Is such a statement acceptable to the RDBMS police? If I use this SQL to make a cursor and BROWSE, it seems to work. Mycursor.Keyfieldstr has type C and correct values, and no error messages. But when I put this statement in the combo.Rowsource, I still get a numeric combo.value. Should I leave the combo.Rowsource blank and make the cursor in the combo.Init? In the combo.Init, I could say
>>>
>>>SELECT field1, field2, keyfield,"" AS keyfieldstr;
>>> INTO CURSOR mycursor ORDER BY keyfield
>>>REPLACE ALL keyfieldstr WITH ALLTRIM(STR(keyfield)) IN mycursor
>>>* a bunch of code to make mycursor read-write
>>>SELECT 0
>>>lnSelArea=SELECT()
>>>USE DBF("mycursor") in (lnSelArea) AGAIN ALIAS NewAlias
>>>SELECT mycursor
>>>USE
>>>SELECT 0
>>>lnSelArea=SELECT()
>>>USE DBF("NewAlias") IN (lnSelArea) AGAIN ALIAS mycursor
>>>SELECT NewAlias
>>>USE
>>>SELECT mycursor
>>>*(whew)
>>>THIS.RowSourceType = 3
>>>THIS.RowSource = mycursor
>>>
>>>I guess I should USE IN mycursor in the combo.Destroy.
>>>
>>>Or is there a better way?
>>
>>A few corrections. The REPLACE ALL command should go after the *(whew), and THIS.RowSourceType = 2, not 3. But I am still getting a numeric combo.Value. Why?
>
>
>Bret
>
>1. Have you checked to be sure that your BoundColumn property is set to the correct field?
>
>2. Personally, I have had no trouble using STR() in Selects. Alltrim is another matter entirely. That's a no-no. Perhaps something as simple as
>
>SELECT str(keyfield,5), field1, field2 from ..... into MyCursor
>
>Then set the combo RowSource to Mycursor, requery and go. I have a VFP3 system with a numeric ID (blame the client, _I_ couldn't have done it) running with this code. Don't use AllTrim, as it affects the field length in the cursor.
>
>HTH
>Barbara

I checked the BoundColumn. I got rid of the ALLTRIM(). I tried using the SELECT in the combo.Init and directly in the combo.Rowsource, in which case combo.Rowsourcetype = 3. I even removed the keyfield from the SELECT and made sure that all SELECTed fields were character. I am still getting the ListID in the combo.Value. Oh, well, I'll just do as Mr. Booth says and use THIS.List(THIS.ListIndex,6). Since this combo won't have a controlsource, I'll have to do something in the combo.GotFocus to make it select the record in the rowsource which matches the record for that row of the grid. I should probably make the column with the combo have width 0 when not in "edit mode", and make it display something other than a field value when in edit mode, but not selected. What a pain. It almost seems easier to rip up my keys and make them characters.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform