DroidDB Tip of the Month
DroidDB® Tip for September 2016
Preventing the End-User From Moving From One Tab to Another
If your form has multiple tabs, you may want to force the user to complete one tab before going to the next. It's a bit tricky, but it can be done.
There are four features in DroidDB's form designer that you can use to do this:
- If you select EDIT | MACROS/EVENTS and then click the EVENTS button, you will see a dropdown labeled "On Startup". Here you can select a macro to run when the end user first runs the form.
- If you select EDIT | MACROS/EVENTS and then click the EVENTS button, you will see a dropdown labeled "On Select Tab". Here you can select a macro to run when the end user selects another tab.
- In an expression, you can use the function @currenttab to determine the currently selected tab (0 for the first tab, 1 for the second, 2 for the third, etc.).
- A step in a macro can be "Select tab" which, when executed, will force a particular tab to be dislayed.
First, create a form in the form designer you want to put this feature into:
- Select FILE | NEW FORM. When asked if the form has an underlying table, select NO.
- Select FORM | TABS
- Click ADD BEFORE and give the tab the name "Tab A" (without the quotes). Click OK
- Click ADD AFTER and give the tab the name "Tab B" (without the quotes). Click OK
- Click OK
- Select CONTROL | CHECKBOX. When asked to select a column or variable, select @var(34). Click OK.
- Set "Text" to "Click me" (without the quotes) and click OK to close the properties dialog.
- Drag the checkbox control to the center of the form
What we want to do is to disallow the user from going from Tab A to Tab B unless the Click Me checkbox is checked.
To do this, here's what you have to do in the form designer:
- Select EDIT | MACROS/EVENTS
- If not prompled for the name of a macro, click NEW
- In the Macro Name dialog, set the name to "MyStartup" (without the quotes) and click OK
- Click ADD BEFORE
- Change "Record | Close" to "Assign"
- For "Value", specify "@currenttab (without the quotes); for "Col", specify "@var(35)" (without the quotes).
- Click the "Events" button
- In the On Startup dropdown, select "MyStartup". Click OK
- Click NEW
- In the Macro Name dialog, set the name to "MySelectTab" (without the quotes) and click OK
- Click ADD BEFORE
- Change "Record | Close" to "Skip"
- For "Num", specify "if @var(34) then 0 else 2" (without the quotes).
- Click ADD AFTER
- Change "Record | Close" to "Assign"
- For "Value", specify "@currenttab (without the quotes); for "Col", specify "@var(35)" (without the quotes).
- Click ADD AFTER
- Change "Record | Close" to "Skip"
- For "Num", specify "2" (without the quotes).
- Click ADD AFTER
- Change "Record | Close" to "Select tab"
- For "Num", specify "@var(35)" (without the quotes).
- Click ADD AFTER
- Change "Record | Close" to "Message box"
- For "Msg", specify 'Please check the checkbox' (WITH the quotes).
- Click the "Events" button
- In the On Select Tab dropdown, select "MySelectTab". Click OK
- Click CLOSE
- Click FILE | SAVE and save your form