Page 1 of 1

SOLVED - How do I get the current selection of a combobox

Posted: Mon Jul 25, 2011 7:19 pm
by admin12
The following code draws an error and tells me no such object exists around "fldGender"

Now fldGender is a combo box where you can either choose Male or Female.

Here is the code:

================================================

--Now save to CandidateCC

put the text of field "MonthEntry" &space & the text of field "DayEntry" &comma & space & the text of field "YearEntry" into DOB

--answer DOB

put "INSERT INTO candidatecc (CandidateCCID,FirstName,MiddleName,SurName,Gender,DOB,EmailAddr,PrimTele,ecn,skype,promo_code) VALUES ("&CandidateCCID & "," &numtochar(39) & the text of field "fldFirstName" &numtochar(39) & "," &numtochar(39) & the text of field "fldMiddleName" &numtochar(39) & "," &numtochar(39) & the text of field "fldSurName" &numtochar(39) & "," & the text of field "fldGender" &numtochar(39) &numtochar(39) & "," &numtochar(39) &DOB &numtochar(39) & "," &numtochar(39) & the text of field "fldEmailAddr" &numtochar(39) & "," &numtochar(39) & the text of field "fldPhoneNum" &numtochar(39) & "," &numtochar(39) & the text of field "fldEmergencyNum" &numtochar(39) & "," &numtochar(39) & the text of field "fldSkype" &numtochar(39) & "," &numtochar(39) & the text of field "fldPromoCode" &numtochar(39) & "," & ")" into theQuery3

answer theQuery3

revExecuteSQL dbID, (theQuery3)

answer "Information saved"

=====================================================

Can anyone help me spot the problem or is there a different way to deal with a combo box (other than 'the text of field "fldGender"')

Thanks.

Mike

Re: I just cannot find the culprit here

Posted: Mon Jul 25, 2011 8:13 pm
by dglass
The text of a combobox is the list of options. The label is the text of the selection, or whatever was typed into the entry area.

Re: I just cannot find the culprit here

Posted: Mon Jul 25, 2011 8:20 pm
by bn
Hi Mike,

a combobox is a button, not a field. To get at the current selection of a combobox use the menuhistory. It is a number corresponding to the line number of the text of the button "myComboboxButton"

Code: Select all

on mouseUp
   put line (the menuhistory of btn "gender") of the text of btn "gender" into field 1
end mouseUp
or a little shorter:

Code: Select all

on mouseUp
put line (the menuhistory of btn "gender")  of btn "gender" into field 1
end mouseUp

You might want to put numtochar(39) into a variable / constant. It saves a lot of typing and makes your code easier to read.

Code: Select all

put numtochar (39) into SQ
It would also be helpful for others that just read the topic of your post if it would be more specific. Like: "How do I get the current selection of a combobox" or somesuch.

Kind regards

Bernd

Re: I just cannot find the culprit here

Posted: Mon Jul 25, 2011 8:26 pm
by admin12
Great ideas. Still not fixed.

Mike

Re: How do I get the current selection of a combobox

Posted: Thu Jul 28, 2011 4:17 pm
by admin12
Still not fixed, but I will try the above and see what happens.

How would I populate the combobox with saved data from the database. I can populate all the other fields, but comboboxes seem to elude me.

So, for example,

set the itemDel to tab
repeat for each line myLine in theData
put item 1 of myLine into field "fldCityBirth"
put item 2 of myLine into field "Country1"
put item 3 of myLine into field "Country2"
put item 4 of myLine into field "Country3"
put item 5 of myLine into field "fldVidLink"
put item 6 of myLine into field "fldRef1"
put item 7 of myLine into field "fldRef2"
put item 8 of myLine into field "fldRef3"
put item 9 of myLine into field "fldCert"
put item 10 of myLine into field "fldPassBioPage"
put item 11 of myLine into field "fldProofSS"
put item 12 of myLine into field "fldPoliceBC"
put item 13 of myLine into field "fldTandC"
put item 14 of myLine into field "cmbIntNotes"
put item 15 of myLine into field "fldContract"

end repeat

populates the fields with existing data after I read it from the database with a SELECT query.

However, the Countries are not fields, but comboboxes. How do I populate those properly?

I also tried:

put item 2 of myLine into the text of btn "Country1"

and

put item 2 of myLine into btn "Country1"

Neither worked?

Mike

Re: How do I get the current selection of a combobox

Posted: Thu Jul 28, 2011 6:15 pm
by Klaus
Hi Mike,

you are looking for the LABEL property!
..
set the label of btn "Country1" to item 2 of myLine
...


Best

Klaus

Re: How do I get the current selection of a combobox

Posted: Thu Jul 28, 2011 7:30 pm
by admin12
That did it. Thank you.

Mike