Discussion Locked

Help needed for Microsoft Access 97

0 helpful
6 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

Hi,

1) I have a primary key whose datatype is autonumber. Is there any way I can format it to something like "cust00001" instead of just "1"?

2) Is Microsoft Access 97 able to handle multiple entries into a field. If it could be done, how?

Thanks
eliz

6 replies

by mckown

I believe that both of these problems can be handled programmatically (through VBA, for example).

Autonumbers are numbers only. However, you should be able to format the number in a display or report like this: PrimaryNbr=right("cust00000",9-len(str(autonumber)) & str(autonumber).

I'm assuming that an example of your second question is how to put in "brown," "green," and "red" for a field that asks for a color. You could write a snippet to add to the field's contents, but a better solution is generally to add child records (one-to-many relationship)--especially if this is data that is important to parse later and/or this is common for this field.

Hope this helps!

by anthony m

One other point that you may want to consider for question two is to set the text box to new line in field to allow the return key to be used. This only works if you are using a form to input data and not straight into the table.

Hope this helps

by shanghai sam

Hi
It is not possible to do what you are doing automatically. There are no means that u can have characters with digits in an auto number field and get it incremented automatically. Only option if u have to do is that u keep the data type to Text and in the form u automatically get the maximum ID and increment it and concatinate ur lable u want in the beginning. Care should be take to do so cz if someone else connected to the same db gets the same ID value as u do, u may end up with one of u losing the record being unable to insert. What you can do is put a save button on the form which gets, increment, concatinate and store bak the value in one go reducing the chance of above problem. Talking sincerely, you should better keep your IDs (primary keys) as Numbers or Autonumbers as they are faster to index.
If u just need this to b shown out 2 the user as concatinated u can store only number and can concatinate it with string whenever u want, thats just a bad idea again.

I am not clear about what u mean by multiple values. Please clear the question,

may b u want to store more than one strings in one field. Whenever you are storing data in a database, its a basic concept that u put just one value in one field, but if u want to store lets say multiple lines of text in a text field, its kinda possible.

Easiest way to test this is in a table with a text or memo field, creat a form and make the text box multiline . Continue typing in it even on multiple lines, you'll get something u are trying to ask

Or may b you'r trying to ask about having two values in primary key, called a composite key

You can select 2 fields in the design view at a time and press primary key button in the title bar, you'll ge a composite key with those two fields. You can get composite key of even more than 2 fields too with the same procedure

Hope this answers ur question, if not, feel free to comment

BA

This discussion is closed to new replies.