Multiple records

J

Jawad

If I change the "Enter Key Behavior" for a textbox used in a form to "New
line in field", will each line be saved in a separate record?

If not, how can I do it? Do I need a code?

Thanks,
 
O

Ofer

No, Usually when you press the Enter key, it will move to the next field, so
if you want the enter key to start a new line in the same text box, and in
the same records, you need to make the changes that you just specified

So, by pressing the enter key it will move to the next field, until it gets
to the last field in the TAB order, and then it will jump to a new record

Now, the question is, when do you want to move to a new record?

You can do it with this line of code
DoCmd.GoToRecord , "", acNewRec
 
J

Jawad

I want to move to a new record every time I hit the "Enter" key.
In other words, I want each line in the text box to be stored in a separate
record.

What do I do?
 
O

Ofer

If there is only one field in the form, then you dont need to do anything,
unless you changed the setting of EnterKeyBehavior, then change it back to
Default

If there are more fields in the form, but you want to move to a new record
every time you press enter in a certain field, then make sure that this field
is last in the Tab Order.
 
J

Jawad

There are more than one fields in the form and there are command buttons as
well, so when I hit the enter key it does open a new record, but it moves to
the next object in the form (in my case a command button). How can I keep the
mouse pointer in the text box? Changing the "Enter key behavior" to “New line
in field†is not creating a new record for me.

Any thoughts?
 
O

Ofer

When you say that you want to add another record in that text box, do you
want to add only in that text box, or in all the fields in the form.

If you want to add only to that text box few records, it sound like a case
for a sub form that handles this text box with another table, that has a one
to many relationship to the original table.

If you want to add a new record, and then stay in the same field, all the
other fields will be empty, and most chances, that you'll get error of key
violation.

I need more details, so I can help you
 
J

Jawad

Yes, I want to add new records only to one text box. Let me explain exactly
what I have...

1. I created a table called "Stock count" with two fields: "AWB number" and
"Date".

2. For this table I created a form for the users to enter the data. I called
it "Stock count_frm".

3. The form has two text boxes and two command buttons.
a. The command buttons are irrelevant now, ignore them.
b. The text boxes on the other hand are important; one text box is set to
capture the date and store it in its proper field "Date" located in the
"Stock count" table, and the other text box is used to enter the "AWB number"
and store it in its proper field in the "Stock count" table.

4. The problem is that I have too many AWB numbers to enter each day, and I
don't want the users to enter them manually; to avoid human error. I want
them to "copy" the AWB numbers from their source (Excel sheet), and "paste"
them directly in the text box. Of course this way each AWB number will be on
a separate line.

5. When I changed the "Enter Key Behavior" for the text box to “New Line in
Fieldâ€, I was able to "copy" and "paste" easily (each AWB number was on a
separate line in the text box). The problem was that each AWB number (i.e.
each line) was not stored in a separate record in the corresponding table
(Stock count). And when I close the form page, I get this message: "The value
you entered isn't valid for this field"

What can I do??
 
O

Ofer

In that case changed the setting of EnterKeyBehavior back to Default

And set the TabStop property of all the controls in the form, except of the
AWB field, to No.

That way every time you press enter it should jump to the next record
 
J

Jawad

I did that, and it worked. But in this way I'll have to enter one AWB number
at a time! And this won't exactly be practical; I have so many numbers. I
need a way to enter all the AWB numbers at the same time, while still storing
each one on a separate record.

I still can't understand why the "Enter key behavior" does not work when I
set it to "New Line in Field"... and what about the message I get, what does
it mean?

Can you help me?
 
O

Ofer

As I explained in the first post the Enter key behavior will change it in a
way that every time you press the Enter key it will strart a new line in the
same field and not in the different records.

Sorry
 
J

Jawad

I see, thanks anyway.

Ofer said:
As I explained in the first post the Enter key behavior will change it in a
way that every time you press the Enter key it will strart a new line in the
same field and not in the different records.

Sorry
--
The next line is only relevant to Microsoft''s web-based interface users.
If I answered your question, please mark it as an answer. It''s useful to
know that my answer was helpful
HTH, good luck
 
Top