Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Unique Constriants on datawindow level

Status
Not open for further replies.

late2town

Programmer
Dec 10, 2009
4
US
Hi

Can we make an unique constraint(or implement the same functionality that an unique constraint does in database) on a column in a datawindow object so that it does not allow same values while entering new rows? I can do that by putting script in itemchanged but wanted to find out is there any smarter way to do the same.

Thanks
 
In itemchanged you give the user immediate feedback on the error. You could also check after all entry is done and prior to saving the records (similar to web page functionality). If you use itemchanged make sure you trigger an accepttext prior to saving the records to account for the user clicking on 'save' after entering the last column but without tabbing out of it.

Matt

"Nature forges everything on the anvil of time
 
easiest way:
-----------
- have an unique index on your columna in the db
- DO UPDATE the dw, but without doing COMMIT, if there's a unique value problem the dberror() event will be triggered.
(the update() function has flags that implay an accepttext() and that allow you to reset the updateflags automatically or by using the resetupdate(flags?) function of the dw or not. you might wanna play with those.)


if you want to be more complicated:
-----------------------------------
try this:

add a retrieval argument to your datawindow 'adw_this' of type datawindow.

do this.retrieve(this), so the adw_this has the value of your datawindow.

create a global function
int gf_validate_dw( datawindow adw_this)

within the function you use the find() function to see if the value already exists in adw_this.

regards,
Miguel L.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top