Enter Key behavior

A

Al Westerlund

I have a form that our receptionists use to enter a
reporting probationers name. This name will then show up
on a probationer officers desktop in an access form
filtered for that particular agent. When the form comes
up for the receptionist, she enters the agents 4 digit
agent code and then goes to the next field to enter the
reporting probationers name. All goes ok if she tabs to
the next field. However, if the enter key is pressed at
any time, it closes the form and does not save the entry.
This has caused some confusion. I have the Keyboard
option set in Options to go to the next field and in all
my other forms is works as expected. The one difference
in this form is it also has a subform on it. The subform
has only one field (the agent name). There is a
relationship between the reporting table and the agent
table. The agent table has the agents code and their name
and the reporting table only has the agent code. I put
the subform with the name field in the form so that the
receptionist will see the name of the offender to confirm
that she put the agent code in for the proper agent. I am
a newcomer to Access as previously in programmed in
ObjectPal. There are a lot of things I like about Access
but the data model in Paradox made it much easier to add
fields from seperate tables without creating subforms.
Could somebody tell me how to correct the Enter key
behavior for this form? I strongly suspect it is the
subform that is causing the problem since my other forms
work OK. Or alternatively, is there a way to put fields
from other tables on a form without putting a subform on
the form? Thanks in advance for your help.
 
C

craig

Hi

what are your property settings in the 'Other' tab under
Enter Key Behaviour ??? this could be the cause.

Regards
 
E

Elwin

Is there any kind of 'Close' button on your form? If so,
check the properties of the control. Its 'Default'
property should be set to 'No'.

If a form contains any command button with the 'Default'
property set to 'yes', it will execute the OnClick() event
of that button when the enter key is pressed. I hope its
this simple. Good luck.
 
A

Albert D. Kallal

If you have any button like a ok button, or a cancel button on the form,
check the property setting.

There is a option in the "other" tab called "default". If any command button
on your form has this set to "Yes", then hitting the Enter key will fire
that button.

You can also make any button get pressed via the Esc key. If you set the
command button "cancel" to "yes", then the Esc key fill fire the button.

so, check any of your command buttons. (and, keep in mind, that for dialog
boxes, and other types of forms, you might want the Enter key to fire a
button for you..so that "default" option can be useful).

Now, for your other problem:

You have a LOT of possibility here. I think for just ONE field that you need
to display from that other file, you can droop the whole sub-form and use a
dlookup.


Just place a text box on the screen, and use:

=(dlookup("offeder Field","agentTable","id = " & agentCode))

Now, the above is a bit of hand full of a expression. You could also base
the form on a query, and with that query simply join in that other lookup
value. This would save you the messy dlookup command.

I mean, using a whole sub form just to lookup a value is a bit much.
Further, the sub form really is useful for a one to "many" relational. For
just looking up values, you should use a combo box, or the above dlookup.

Note that you can use the wizard to make the combo box. In fact, try placing
two combo boxes on your form. Each combo box will be based on your "agent
id" field, but you can have the combo display a differnt value. Often, we
do use a combo box to lookup a value in the other tables.
 
A

Al Westerlund

Thanks a bunch! It was the default behavior that was the
problem. I had the default behavior on the Cancel button
set to Yes. I changed that to No and it solved the
problem. It was No on the Save and close button and I
changed that to Yes as I do want Enter to trigger that
button. Definitely solved my problem.
As to the other issue, I agree the subform is an unwieldy
way to do a lookup. It was also a pain to do it that way.
I am new to Access and am learning my way. I don't really
want to go the query route but I will look into how to do
the Combo box. I don't really know how to do that but I
will research it before looking for help here. I will
also look at the dlookup method. With the subform there
is a slight delay before the agent name shows. Perhaps
the dlookup will go quicker. Again, thanks for your help.
Al Westerlund
 

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

Similar Threads


Top