Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Define field length for query results

Posted on 2008-06-26
5
Medium Priority
?
830 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 2000 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

Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

Question has a verified solution.

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

Cancel future meetings from user mailboxes in Office 365 using Remove-CalendarEvents
One of the most important things in an application is the query performance. This article intends to give you good tips to improve the performance of your queries.
Learn how to create and modify your own paragraph styles in Microsoft Word. This can be helpful when wanting to make consistently referenced styles throughout a document or template.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

618 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