checkbox FIELD property does not update the field

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

Post Reply
User avatar
raumi75
Posts: 135
Joined: Wed Dec 17, 2008 2:31 am
Location: Lünen, Germany
Contact:

checkbox FIELD property does not update the field

Post by raumi75 »

Hello everyone,

sorry for not posting for so long. I have been busy with other projects but now I am back with my favorite programing language: HMG!

I noticed a strange behavior of the checkbox.

I used the FIELD-property and expected it to work just like in a TEXTBOX-control. It reads the value from the database field and when the user updates the control, the database field gets changed, too.

Code: Select all

FIELD db->field
But in CHECKBOX, it displays the correct value (true = checked / false= unchecked) as it is saved in the database. But when I click to check or uncheck it, the database value does not get changed.

I have to do this by hand by supplying an ON CHANGE command.

Code: Select all

ONCHANGE db->field := this.value
Am I doing something wrong or is this a bug in HMG?

Yours

Raumi
User avatar
Roberto Lopez
HMG Founder
Posts: 4023
Joined: Wed Jul 30, 2008 6:43 pm

Re: checkbox FIELD property does not update the field

Post by Roberto Lopez »

raumi75 wrote:Hello everyone,

sorry for not posting for so long. I have been busy with other projects but now I am back with my favorite programing language: HMG!

I noticed a strange behavior of the checkbox.

I used the FIELD-property and expected it to work just like in a TEXTBOX-control. It reads the value from the database field and when the user updates the control, the database field gets changed, too.

Code: Select all

FIELD db->field
But in CHECKBOX, it displays the correct value (true = checked / false= unchecked) as it is saved in the database. But when I click to check or uncheck it, the database value does not get changed.

I have to do this by hand by supplying an ON CHANGE command.

Code: Select all

ONCHANGE db->field := this.value
Am I doing something wrong or is this a bug in HMG?

Yours

Raumi
Welcome again.

I'll check it ASAP.
Regards/Saludos,

Roberto


(Veritas Filia Temporis)
User avatar
esgici
Posts: 4543
Joined: Wed Jul 30, 2008 9:17 pm
DBs Used: DBF
Location: iskenderun / Turkiye
Contact:

Re: checkbox FIELD property does not update the field

Post by esgici »

Hi Raumi

Are you sure in this sentence :

Code: Select all

ONCHANGE db->field := this.value
db is alias of your database file ?

If not, may be this is the problem.

Also, AFAIK FIELD is a reserved word and using it as a field name may be causing problem.

Moreover you may try REPLACE command or FIELDPUT() function instead of assignment operator ( := ) for changing content of a database file fields.

Regards

--

Esgici
Viva INTERNATIONAL HMG :D
User avatar
raumi75
Posts: 135
Joined: Wed Dec 17, 2008 2:31 am
Location: Lünen, Germany
Contact:

Re: checkbox FIELD property does not update the field

Post by raumi75 »

esgici wrote:Hi Raumi

Are you sure in this sentence :

Code: Select all

ONCHANGE db->field := this.value
db is alias of your database file ?

If not, may be this is the problem.

Esgici
No. This not the real code. Just an example to show, what I did. The real code has variables in German, so I tried to simplify it a little bit.

The ONCHANGE event does the trick and my program runs fine.

It is just, that for other hmg-controls, the FIELD property also updates the database field and I don't have to write any ONCHANGE method. So if it is not a bug, it is at least a little inconsistent. And we know, how much Roberto loves consistency and simplicity. So I thought this worth mentioning.

Maybe Roberto can reproduce my error.

Raumi
User avatar
esgici
Posts: 4543
Joined: Wed Jul 30, 2008 9:17 pm
DBs Used: DBF
Location: iskenderun / Turkiye
Contact:

Re: checkbox FIELD property does not update the field

Post by esgici »

Hi Raumi

Sorry, I'm misunderstood your question :(

And, checked <hmg>\SAMPLES\DATA.BOUND\datacontrols.prg :

We need separate "save" method each data.bound control for saving changed field value/content to database file.

Simply navigate (next/previous...) between records doesn't save data.

I don't know you have already done this.

Regards

--

Esgici
Viva INTERNATIONAL HMG :D
User avatar
raumi75
Posts: 135
Joined: Wed Dec 17, 2008 2:31 am
Location: Lünen, Germany
Contact:

Re: checkbox FIELD property does not update the field

Post by raumi75 »

esgici wrote:Hi Raumi

Sorry, I'm misunderstood your question :(

And, checked <hmg>\SAMPLES\DATA.BOUND\datacontrols.prg :

We need separate "save" method each data.bound control for saving changed field value/content to database file.

Simply navigate (next/previous...) between records doesn't save data.

I don't know you have already done this.

Regards

--

Esgici
Thank you for pointing me to the DATA.BOUND samples. I am now playing with it.

If you add dbcommit() to the SAVE procedure, it stores your changes in the database.

Surprisingly, the TEXTBOX and CHECKBOX behave the same in the sample. I think, I will have to take a closer look at my own code. I hope, I am not wasting your time.

Raumi
User avatar
esgici
Posts: 4543
Joined: Wed Jul 30, 2008 9:17 pm
DBs Used: DBF
Location: iskenderun / Turkiye
Contact:

Re: checkbox FIELD property does not update the field

Post by esgici »

raumi75 wrote: ...
I hope, I am not wasting your time.
Absolutely no, my friend, everything is for HMG and HMG community :D

Regards

--

Esgici
Viva INTERNATIONAL HMG :D
User avatar
raumi75
Posts: 135
Joined: Wed Dec 17, 2008 2:31 am
Location: Lünen, Germany
Contact:

Re: checkbox FIELD property does not update the field

Post by raumi75 »

OK. I have found my bug. HMG works fine. Sorry for this post.

Thanks giving me the right hints!!

Raumi
User avatar
Roberto Lopez
HMG Founder
Posts: 4023
Joined: Wed Jul 30, 2008 6:43 pm

Re: checkbox FIELD property does not update the field

Post by Roberto Lopez »

raumi75 wrote:OK. I have found my bug. HMG works fine. Sorry for this post.

Thanks giving me the right hints!!

Raumi
No problem and congratulations for your great victory!!!

And thanks for the help Esgici.
Regards/Saludos,

Roberto


(Veritas Filia Temporis)
Post Reply