Recent

Author Topic: Saving hidden data-ish  (Read 1745 times)

Glewins

  • New member
  • *
  • Posts: 8
Saving hidden data-ish
« on: February 03, 2018, 10:48:35 pm »
I have 2 groups using a single pick list.  I want one group to see only their own data.  Human resources and First Aid will be using the tablr.
Example:
Table = Gender
Field1 = Gendername varchar(30)
Field2 - Gendercode varchar(1)

When a First aider opens the form, the sql is like -> select x from gender where gendercode='F' order by Gendername.  This all works.
When a Human Resources opens the form, the sql is like -> select x from gender where gendercode='H' order by Gendername.  This all works.

On the form, I leave a dbedit invisible, once the user adds a gender, on the exit, I add the corresponding 'H' or 'F', then do a post. Commit;

The Gendername is saved but the gendercode is not.

Any ideas?

George Lewins



valdir.marcos

  • Hero Member
  • *****
  • Posts: 1106
Re: Saving hidden data-ish
« Reply #1 on: February 04, 2018, 04:54:45 am »
Please, show some code.

Maybe, you missed something on your SQL text.
For example, you might think you are saving both fields, but your SQL text might be such as:
Code: [Select]
Update Gender
Set Field1 = :Gendername;

rvk

  • Hero Member
  • *****
  • Posts: 6163
Re: Saving hidden data-ish
« Reply #2 on: February 04, 2018, 01:35:39 pm »
On the form, I leave a dbedit invisible, once the user adds a gender, on the exit, I add the corresponding 'H' or 'F', then do a post. Commit;
Instead of an hidden TDBEdit you can also just set the value directly.
Code: Pascal  [Select][+][-]
  1. SQLQuery.FieldByName('gendercode').asString := 'F'; // or 'H'
  2. SQLQuery.Post;
  3. SQLQuery.Commit;
You don't need a TDBEdit for that (especially if you don't show it anyway).

You do need to have the gendercode in your SELECT.

 

TinyPortal © 2005-2018