Source language: Translate to:

Prevent a new Record in dbpSetGridProperties

Questions about our Advanced Database plug-in

Moderator: Neosoft Support

Prevent a new Record in dbpSetGridProperties

Postby Stefan » Thu May 29, 2008 2:20 am

I have a table and i show the Query-Selection in a grid for the user, to set the values in one Collumn.
One of the fields is not shown, because it define the number of the table.

The Navigation-bar is not shown, because i do not want, that the user can generate a new record.
BUT - have i now a possibility to prevent to generate a new record, if the user is on the last record in the grid and press ENTER/TAB KEY?

Because, the grid will make a new record, but the number of the table is empty (field is not shown) and so we become a database-error, because the record is empty.....

Thanks for a tipp!
Stefan
Stefan
 
Posts: 35
Joined: Mon Dec 03, 2007 7:00 am

Postby Neosoft Support » Thu May 29, 2008 9:33 am

Try setting the grid to read-only. For example:

dbpSetGridProperties "AddrBook" "Contacts" "ReadOnly=Yes"
NeoSoft Support
Neosoft Support
NeoSoft Team
 
Posts: 5593
Joined: Thu Mar 31, 2005 10:48 pm
Location: Oregon, USA

Postby Stefan » Fri May 30, 2008 4:10 am

Thanks for the tipp, but it doesn't work:

with the command:
dbpSetGridProperties "AddrBook" "Contacts" "ReadOnly=Yes"
It's not possible to chane a field in the table, also not when ich declare after the above command:

dbpSetFieldProperties "AddrBook" "Contacts" "name" "ReadOnly=No"

The goal is, that the user can change the values of one field over several records in a table, but i must prevent that the user can generate a new record. But if you are in the table, on the last record and you press ENTER/TAB, then it will generate a new record. A record who has not all information he needed to save it. The user see not all fields in the table, so it is not possible to save/delete this record, i becom a database-Error-Message: a empty record can't be entered, mimimum one field must have....

Stefan
Stefan
 
Posts: 35
Joined: Mon Dec 03, 2007 7:00 am

Postby Neosoft Support » Fri May 30, 2008 10:41 am

I understand. unfortunately, this is the default behavior of the database grid component. however, it may be possible to change it by rewriting part of the component. I will add this to the list of things to correct in the next update.

Just so we're clear, when the navigation bar is turned off it should not be possible to add a new record from the grid. Will that cause problems for anyone else?
NeoSoft Support
Neosoft Support
NeoSoft Team
 
Posts: 5593
Joined: Thu Mar 31, 2005 10:48 pm
Location: Oregon, USA

Postby Gaev » Fri May 30, 2008 11:22 am

Stefan:

I have not tried any of these workaround suggestions but ...

But if you are in the table, on the last record and you press ENTER/TAB, then it will generate a new record. A record who has not all information he needed to save it. The user see not all fields in the table, so it is not possible to save/delete this record,
You might consider using a "subroutine" in your dbpOpenTable command ... and have this routine check for records with a "blank" field content ... and delete it if found ... if you choose to persue this, please refrain from doing the deletion from within the subroutine ... instead, TimerStart a "run once" Timer object ... whose Timer Interval code does the deletion.

You might also consider turning dbpSetAutoEdit to "No" ... and then ... before you do a manual dbpSaveEdits ... make sure you delete any records with empty fields.

with the command:
dbpSetGridProperties "AddrBook" "Contacts" "ReadOnly=Yes"
It's not possible to chane a field in the table, also not when ich declare after the above command:

dbpSetFieldProperties "AddrBook" "Contacts" "name" "ReadOnly=No"
You might consider setting up your grid with the ReadOnly=Yes parameter ... then simulate the edit function by ...

- specifying a subroutine for OnDoubleClick=subroutine in dbpSetGridProperties

- in this subroutine, you can "popup" a (borderless, exclusive) CustomWindow with a TextEntry Box and OK and Cancel buttons ... you can get information about the exact cell that was double clicked using dbpGetActiveField ... and the variable [yourDB.yourTable.$RecNum]

- you can position the CustomWindow at/close to the point where user double clicked using GetMousePos
User avatar
Gaev
 
Posts: 3717
Joined: Fri Apr 01, 2005 7:48 am
Location: Toronto, Canada


Return to NeoBookDBPro

Who is online

Users browsing this forum: No registered users and 1 guest

cron