×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

[Solved]Reading from DBF file and assigning value to checkbox

[Solved]Reading from DBF file and assigning value to checkbox

[Solved]Reading from DBF file and assigning value to checkbox

(OP)
Hello everyone,

Is it possible to have a DBF file with some values (e.g. field01...field16 with bool values) and
assign that value (and enabling the checkbox) to a checkbox with similar naming?
The code for the loop doesn't seem to work, the values aren't set, the checboxes are disabled.

My form contains checkboxes with the naming "_chkV01" until "_chkV16".

My example code for that loop:

CODE -->

SELECT <DBF-file>
SET ORDER TO <order-field>
  SEEK <order-value>
  IF FOUND()
    FOR i = 1 TO 16
      oCheckboxValue = EVALUATE("thisform._chkV"+STRTRAN(STR(i,2),' ','0'))
      oCheckboxValue.Enabled = IIF(EVALUATE("value"+STRTRAN(STR(i,2),' ','0')),.T.,.F.)
      oCheckboxValue.Value = IIF(EVALUATE("value"+STRTRAN(STR(i,2),' ','0')),1,0)
    ENDFOR
  ENDIF 

If I do things normally like this (16 times...):

CODE -->

thisform._chkV01.Value = IIF(value01,1,0) 

But it feels so wrong.

EDIT: Ok, it worked, I forgot about another function which checks if the values are plausible...
That was the culprit of it.

RE: [Solved]Reading from DBF file and assigning value to checkbox

You'd noirmally use the controlsource property and set it to field names.
I question a record design with 16 bool values, I'd rather have 16 records with each 1 bool values and the you can use a grid.
You see from your code complexity that it's not easy to address a series of checkboxes or numbered fields, this is always bad design.

You could do what you wnt without code with drag % drop from the forms data environment to the form. So
1. modify the form
2. open up the data environment. Many ways to do that, one is by menu "View"->"Data Environment"
3. If you don't have anything in the forms dataenvironment you will be asked to specify a table, use your dbf file there
4. Drag the single bool fields into the form 1 by 1 and with each field you get a label and a checkbox bound to that field.

If you don't want the table to be opened by the data environment you could even delete the dbf file from it, the controls will stay on the form and you may open up the dbf file again in init code or whenever you do now. Still too tedious to do? But you did add 16 checkboxes yourself ad had to name them all.

What's not happening is that the checkboxes with .F. value will be disabled, if you really want that (why?) you could program a checkbox calss that does so in its init:

CODE

This.Enabled = This.Value 

A checkbox the is disabled when the value is .f. would now only allow the uncheck a box that's checked and thus enabled. Once it's unchecked it does not automatically disable though. if you want that the same code should be in the interactivechange event, for example.

Chriss

RE: [Solved]Reading from DBF file and assigning value to checkbox

(OP)
Hi!
Thanks for your input!
The problem with the naming is:
I have many products (hundreds) that need some checks (16 items to check if the product is OK).
And the 16 items can vary between each product.

It could be that item 01 can be used to check if product A has the correct outer diameter,
but item 01 can also be used on product B to check if the inner diameter is correct.

And the check has to be double times enabled if the machine does the check AND the human after it has to check that value.
If the machine doesn't have to check the value the human also shouldn't.

That's why I have the bool values numbered, sadly...

Also the problem got solved, I messed up at another part of it when doing a sanity check...

RE: [Solved]Reading from DBF file and assigning value to checkbox

That's all not hindering to put the 16 values into 16 records instead of 16 fields.

Chriss

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login


Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close