Solved

Define field length for query results

Posted on 2008-06-26
5
818 Views
Last Modified: 2008-07-03
I currently have a table of information in access that I need to query certain fields with.  

The issue is that I can not define a field length for the query's results.
For example:
Lname must have a field length of 30 regardless of use
TermHrs must have a field length of 3 regardless of use

I've tried left(), mid(), right(), substr()...and none of them have worked.  
0
Comment
Question by:Jond0312
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
5 Comments
 
LVL 3

Expert Comment

by:darkmooink
ID: 21875806
len()
0
 
LVL 27

Expert Comment

by:jjafferr
ID: 21875844
try this:

Lname1: mid([Lname],1,30)
TermHrs1: mid([TermHrs],1,3)

jaffer
0
 

Author Comment

by:Jond0312
ID: 21875921
I tried

mid([Lname],1,30) & mid([Fname],1,30)

my results...

DerekKellgren

i need

Derek________________________Kellgren______________________
0
 
LVL 27

Accepted Solution

by:
jjafferr earned 500 total points
ID: 21876920
Do you mean you want the rest of the space to be BLANKS? or Underscores??

you will need a Function to do this,
save the following in a module:



now in your query, call this function, like this:
Lname1: FormatText([Lname], 30)
Public Function FormatText(txt As String, iDigits as integer)
dim NewT, i 
    For i = Len(txt) + 1 To iDigits 
        NewT = NewT & " "   'replace the space between the quotes with whatever you want to fill the rest of the spaces
    Next i
    FormatText = txt & NewT
    
End Function

Open in new window

0
 
LVL 27

Expert Comment

by:jjafferr
ID: 21876942
for [Lname]  and  [Fname]

FullName:FormatText([Lname], 30) & " " & FormatText([Fname], 30)
0

Featured Post

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I'm trying, I really am. But I've seen so many wrong approaches involving date(time) boundaries I despair about my inability to explain it. I've seen quite a few recently that define a non-leap year as 364 days, or 366 days and the list goes on. …
AutoNumbers should increment automatically, without duplicates.  But sometimes something goes wrong, and the next AutoNumber value is a duplicate.  This article shows how to recover from this problem.
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question