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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I have a problem with a combo box need some help please

Status
Not open for further replies.

titoneon

MIS
Dec 11, 2009
335
US
Hi Everyone,
in VFP 9.0 SPK2, i have a combo box named cbosht the Style is dropdown list in a form and in the Init event i have this code:

WITH this as ComboBox
.RowSourceType= 3
.RowSource = "Select alltrim(sht)+'-'+ALLTRIM(layout) As shtlayout, sht, layout From "+;
"eng_shtd Into Cursor Ceng_shtd where job_no = Alltrim(Thisform.txtJobn.Value) Order By sht NOFILTER"
.BoundColumn = 2
.BoundTo = .T.
.Style = 2
ENDWITH


In my command save click i have this:

lcsht = thisform.Cbosht.DisplayValue
lclayout = thisform.cbosht.Value

Insert Into datatest (employee, Time, job_no, Day, TIME_TYPE, Code, descode, extradesc, work_type, sht, layout) Values (m.lcEmpNo, m.lnHours, m.lcJobNo, m.ldDate, m.lcTimetype, m.lcCode, m.lcdescode, m.lcExtra, m.lcWorkType, m.lcsht, m.lclayout)

the fields in table "eng_shtd.dbf" are as follow

Name type width
job_no C 6
sht C 3
layout C 7
descrip C 40

the other table is "datatest.dbf" where i need to get the values selected from the cbosht, when i save the entry on the form, the fields sht, layout from the combo are getting like truncated and layout is not getting into the datatest.layout, it is like is getting the first character fron the field sht, as well i would like to pass the descrip value from table eng_shtd for the selected record from the combo to the datatest.descrip, datatest.dbf have in common the same fields with the same specifications as the Eng_shtd.dbf of course just the sht, layout and descrip fields.
example if in the form i enter in the textbox a Job_no =103267 then the cobsht, should display only the records in eng_shtd that match that job_no nad list there just column sht and layout, actually it does, but when review in a browse, i can see that in datatest i got the sht replaced as part of the alltrim(sht)+'-', and the layout is a combination of the alltrim(sht)+'-'+ALLTRIM(sht) but i don't even get the whole value into this field, and of course i don't know how to pass the value of the descrip to Datatest.descrip, what could be wrong here ?
Thanks
Ernesto
 
Have you put a SET STEP ON into your save click method code and watched your code execute line-by-line?

If you do, it will launch your TRACE Window and, along with that, your DEBUG WATCH window wherein you can examine the various values along the way.

Also while watching the code execute in your TRACE window, you can put your mouse cursor over parts of the code lines and examine the values dynamically.

Good Luck,
JRB-Bldr
 
Thanks
with the set step on, I can realize what is going on but i am wondering how can i get the field descrip from the eng_shtd table to recorded or replace in the other table while selecting from the combo box the row ?
Thanks
 
with the set step on, I can realize what is going on

That's a BIG Step #1 to this problem and to investigating other problems.

Once you have the DisplayValue from your Combo box, now use it to find the matching record in your eng_shtd table.

While I am not 100% clear on what you are trying to do, something like the following should work:
Code:
lcsht = thisform.Cbosht.DisplayValue
lclayout = thisform.cbosht.Value

SELECT *;
  FROM eng_Shtd;
  WHERE ALLTRIM(sht)+'-'+ALLTRIM(layout) = ALLTRIM(lcsht);
  INTO CURSOR FoundMatch

SELECT FoundMatch
SCATTER MEMVAR

INSERT INTO datatest (employee, Time, job_no, Day, TIME_TYPE, Code, descode, extradesc, work_type, sht, layout) Values (m.lcEmpNo, m.lnHours, m.lcJobNo, m.ldDate, m.lcTimetype, m.lcCode, m.lcdescode, m.lcExtra, m.lcWorkType, m.lcsht, m.lclayout)

Feel free to make any modifications to this example code where you see that I clearly didn't understand what you are after...

Good Luck,
JRB-Bldr



 
You need to use CAST() around the first field in the query you're setting as the RowSource, so that you get a fixed length for that field.

Tamar
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top