detect if arrow key down or up is pressed?

G

Guest

Is it possible to detect if a user presses an arrow (down or up) key. Access
saves a record at that moment and it would make it possible to check if all
necessary fields are filled. By the way: it is a conditional check: if one
field has a specific value two other fields will have to be filled in.
Thanks!!
 
A

Alex Dybenko

Hi,
you can use form's BeforeUpdate event to check that all fields are filled,
if no - show a messagebox and make Cancel=true
 
A

Allen Browne

Alex has answered your question, but you could also do this at the engine
level instead of using code in the form.

Steps:
1. Open the table in design view.

2. Open the Properties box (View menu).

3. Enter this line in the Validation Rule in the Properties box:
(([Field1] = 'Dog') AND ([Field2] Is Not Null) AND ([Field3] Is Not
Null))
OR ([Field1] <> 'Dog') OR ([Field1] Is Null)

The rule can be satisfied 3 ways:
- Field1 contains the text Dog, and the other 2 are not null;
- Field1 contains something other than Dog;
- Field1 contains nothing.
As a result, if Field1 contains Dog, the other 2 fields are required.

Replace your field names and the value with your actual ones.

Note that the Validation Rule in the Properties box is the rule for the
table, and it is not the same as the rule for each field (in the lower pane
of table design.)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top