DroidDB Tip of the Month

DroidDB® Tip for December 2017

Unique Values

You may want to prevent a user from creating multiple records with the same value in a column. You can do this by doing this:

Say You wanted the column RECORD_ID to be unique. First, use FILE | MODIFY TABLE and create an index over the RECORD_ID column. Then, create an edit control connected to @var(35) (not RECORD_ID) that the user will use to specify the new record number.

Then, on your form, create a macro (EDIT | MACRO/EVENTS) called INSERT_RECORD:

  • STEP 1: SORT BY sorting on RECORD_ID
  • STEP 2: RECORD | SEARCH. For "Arg" use @var(35). Set "Skip ... if not found" to 2. Turn on the "Exact matches only" check box.
  • STEP 3: MESSAGE BOX with the "Msg" set to 'Error: duplicate record id'
  • STEP 4: RETURN FROM MACRO
  • STEP 5: RECORD INSERT
  • STEP 6: ASSIGN. For "Value" use @var(35). For "Col" use RECORD_ID
  • STEP 7: RETURN FROM MACRO

Lastly, put a button on the form whose action is RUN MACRO that runs the INSERT_RECORD macro.

When the end user uses the form to create a new record, he should enter the RECORD_ID in the edit control connected to @var(35) and then press the button.

 

Back to List »

Visit our store

Top rated! I needed a solid database application development tool for mobile devices. I chose DroidDB for Android OS because it provided a way to get a strong product to market quickly. DroidDB is relational, gives me control over form layout, handles macros, and supports events. It works on all Android versions I have tried and is a great companion product to SYWARE’s VisualCE.

Mark Read, President
SyntegraTech, Inc.

signup for our newsletter