Discussion Locked

Microsfoft Access Help

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

I have a problem in Access. I am trying to take the data from one column (UniqName), which is a number and and take the first three digits from that number and place it in another column.

I know that I need to declare UniqName a string in order to use the command to take those numbers.

I also now that the built in function to take the first three numbers is:
Left([String], 3)

What I don't know is where and how I declare the string. I need to be walked through this process, step by step.

Please help ASAP

5 replies

by d. brinson

You declare the type of a field in one of two basic ways. One, if the table has been imported, it is defined in the import template. If you have created the table by hand, it is in the table design.

WARNING: NEVER change the table setup unless you are SURE you have a backup of your database.

You can just open the table in design view and change the field type from Numeric to Text.

However, a much easier and safer way of making the change you want is to use the following command in place of Left([String],3) to fill in your new column.

Use:
Trim(Left(Str(UniqName),4))

For some reason, Str seems to return your numeric field in with 1 space in front of it. Trim removes that one space.

by sankulpune

Hello yousuf,

There is no need to declare a string variable. Use
Left(Trim(CStr(UniqName)), 3) whereever you have used UniqName in an expression.

The only time this will cause an error is when the value of Uniqname is less than 100.

SanganakSakha,,
Simple And Effective Solutions To Small Problems, No QuickFixes.

by yousuf_300

I used the recommended command and it didn't give me the error. Unfortunately, the data did not filter out. It merely left the file as blank. I was wondering if it was because I doing it from SQL, but I think that is where I should be doing it from.

This discussion is closed to new replies.