Microsoft Access Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsDatabaseMicrosoft Access Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
SlickEdit: Code in over 40 languages across 7 platforms. SlickEdit’s unmatched power, speed, and flexibility allows even the most accomplished developers to write better code faster. Download a free trial today!
  #1  
Old May 12th, 2008, 11:01 AM
mcianfrani mcianfrani is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jan 2007
Posts: 19 mcianfrani User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 6 h 21 m 57 sec
Reputation Power: 0
Queries - Right justify

How do I right justify? The field is 7 characters long and I've tried this but it no longer brings me any data in fields I've previously had data.

25: Space(7-Len(CLng(Int([rev.250])+Int([rev.255])+Int([rev.258]))))

Reply With Quote
  #2  
Old May 12th, 2008, 01:56 PM
dykebert dykebert is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: May 2008
Posts: 71 dykebert User rank is Sergeant Major (2000 - 5000 Reputation Level)dykebert User rank is Sergeant Major (2000 - 5000 Reputation Level)dykebert User rank is Sergeant Major (2000 - 5000 Reputation Level)dykebert User rank is Sergeant Major (2000 - 5000 Reputation Level)dykebert User rank is Sergeant Major (2000 - 5000 Reputation Level)dykebert User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 18 h 7 m 11 sec
Reputation Power: 21
well first the line you posted would simply return spaces.

25: Space(7-Len(CLng(Int([rev.250])+Int([rev.255])+Int([rev.258]))))

It would need to be modified to return the actual value:

25: Space(7-Len(CLng(Int([rev.250])+Int([rev.255])+Int([rev.258])))) & CLng(Int([rev.250])+Int([rev.255])+Int([rev.258]))

The simpler way to do this would be:
Right(Space(7) & CLng(Int([rev.250])+Int([rev.255])+Int([rev.258])), 7)

Or you could probably use:
Format(CLng(Int([rev.250])+Int([rev.255])+Int([rev.258])), "<7spaces>")

Reply With Quote
  #3  
Old May 12th, 2008, 02:43 PM
mcianfrani mcianfrani is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jan 2007
Posts: 19 mcianfrani User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 6 h 21 m 57 sec
Reputation Power: 0
I'm close. I've tried all of these and they all center the value, not justify it to the right. What am I missing?

Reply With Quote
  #4  
Old May 12th, 2008, 02:50 PM
dykebert dykebert is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: May 2008
Posts: 71 dykebert User rank is Sergeant Major (2000 - 5000 Reputation Level)dykebert User rank is Sergeant Major (2000 - 5000 Reputation Level)dykebert User rank is Sergeant Major (2000 - 5000 Reputation Level)dykebert User rank is Sergeant Major (2000 - 5000 Reputation Level)dykebert User rank is Sergeant Major (2000 - 5000 Reputation Level)dykebert User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 18 h 7 m 11 sec
Reputation Power: 21
Ummmm how are you displaying it?

It sounds like the textbox is wider than the 7 characters and it isn't set to right justify.

Reply With Quote
  #5  
Old May 12th, 2008, 02:59 PM
mcianfrani mcianfrani is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jan 2007
Posts: 19 mcianfrani User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 6 h 21 m 57 sec
Reputation Power: 0
I'm doing it directly in the query so there is no textbox. I'm new so I apologize if that's a stupid response. I can't understand why if I export it to a table and make the text right justified in the properties box for that field, why it won't keep it when I export it.

Reply With Quote
  #6  
Old May 12th, 2008, 03:14 PM
dykebert dykebert is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: May 2008
Posts: 71 dykebert User rank is Sergeant Major (2000 - 5000 Reputation Level)dykebert User rank is Sergeant Major (2000 - 5000 Reputation Level)dykebert User rank is Sergeant Major (2000 - 5000 Reputation Level)dykebert User rank is Sergeant Major (2000 - 5000 Reputation Level)dykebert User rank is Sergeant Major (2000 - 5000 Reputation Level)dykebert User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 18 h 7 m 11 sec
Reputation Power: 21
I know of no way to format the data in a query.

You can change the width of the field being displayed so that it would appear to be right justified or you can add more spaces to the front, again so it appears to be righ justified.

However, if you want to actually format the results of a query you'll have to put it into a form or report.

Reply With Quote
  #7  
Old May 12th, 2008, 03:17 PM
Wolffy's Avatar
Wolffy Wolffy is offline
Slaprentice of Wolves
Click here for more information.
 
Join Date: Aug 2007
Location: Mossville, IL
Posts: 1,246 Wolffy User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Wolffy User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Wolffy User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Wolffy User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Wolffy User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Wolffy User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Wolffy User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Wolffy User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Wolffy User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Wolffy User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Wolffy User rank is Lieutenant Colonel (40000 - 50000 Reputation Level) 
Time spent in forums: 1 Week 6 Days 19 h 54 m 25 sec
Reputation Power: 423
You probably would need to use a monospace font as well. Otherwise, it will never right-justify.
__________________
Wolffy
------------------------
Opinions expressed are my own and do not necessity reflect those of any sane person. Any code provided is intended to be an example and is provided AS IS. Rework for your specific environment may be required. Void where prohibited by law. Not valid in California. Your mileage may vary. Not FDIC insured

Reply With Quote
  #8  
Old May 12th, 2008, 03:28 PM
mcianfrani mcianfrani is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jan 2007
Posts: 19 mcianfrani User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 6 h 21 m 57 sec
Reputation Power: 0
ok, thanks

Reply With Quote
  #9  
Old May 12th, 2008, 09:02 PM
sbenj69's Avatar
sbenj69 sbenj69 is offline
Dark Sonic Apprentice :D
Click here for more information
 
Join Date: Feb 2007
Location: Redneck part of Illinois
Posts: 1,454 sbenj69 User rank is General 2nd Grade (Above 100000 Reputation Level)sbenj69 User rank is General 2nd Grade (Above 100000 Reputation Level)sbenj69 User rank is General 2nd Grade (Above 100000 Reputation Level)sbenj69 User rank is General 2nd Grade (Above 100000 Reputation Level)sbenj69 User rank is General 2nd Grade (Above 100000 Reputation Level)sbenj69 User rank is General 2nd Grade (Above 100000 Reputation Level)sbenj69 User rank is General 2nd Grade (Above 100000 Reputation Level)sbenj69 User rank is General 2nd Grade (Above 100000 Reputation Level)sbenj69 User rank is General 2nd Grade (Above 100000 Reputation Level)sbenj69 User rank is General 2nd Grade (Above 100000 Reputation Level)sbenj69 User rank is General 2nd Grade (Above 100000 Reputation Level)sbenj69 User rank is General 2nd Grade (Above 100000 Reputation Level)sbenj69 User rank is General 2nd Grade (Above 100000 Reputation Level)sbenj69 User rank is General 2nd Grade (Above 100000 Reputation Level)sbenj69 User rank is General 2nd Grade (Above 100000 Reputation Level)sbenj69 User rank is General 2nd Grade (Above 100000 Reputation Level)  Folding Points: 188372 Folding Title: Super Ultimate Folder - Level 1Folding Points: 188372 Folding Title: Super Ultimate Folder - Level 1Folding Points: 188372 Folding Title: Super Ultimate Folder - Level 1Folding Points: 188372 Folding Title: Super Ultimate Folder - Level 1Folding Points: 188372 Folding Title: Super Ultimate Folder - Level 1Folding Points: 188372 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 2 Weeks 5 Days 13 h 38 m 51 sec
Reputation Power: 1077
ummm, may I make a suggestion.... convert those numbers to strings using the str() function you do the len() around the string function:

25: Space(7-Len(trim(str(Int([rev.250])+Int([rev.255])+Int([rev.258]))))) & trim(str(Int([rev.250])+Int([rev.255])+Int([rev.258])))

Now you may need to increase the spaces from 7 for the query view, or shrink the size of the datasheet column in your query view. I think courier font will also work as well as monotype.
__________________
Did I help you? If so gimme rep by clicking on the at the top right corner of this post

Madness does not always howl. Sometimes, it is the quiet voice at the end of the day saying, "Hey, is there room in your head for one more?"

Last edited by sbenj69 : May 12th, 2008 at 09:08 PM. Reason: added more info

Reply With Quote
  #10  
Old May 15th, 2008, 08:10 AM
mcianfrani mcianfrani is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jan 2007
Posts: 19 mcianfrani User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 6 h 21 m 57 sec
Reputation Power: 0
I tried that and it centered it rather than right justified it. I'm using the query to create a table then I export the table to a .txt file and ship it off to the state. I tried going into the properties of the field on the table and left justify it there but it loses it during the export to .txt file. Is it just not doable?

Reply With Quote
  #11  
Old May 15th, 2008, 08:34 AM
dykebert dykebert is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: May 2008
Posts: 71 dykebert User rank is Sergeant Major (2000 - 5000 Reputation Level)dykebert User rank is Sergeant Major (2000 - 5000 Reputation Level)dykebert User rank is Sergeant Major (2000 - 5000 Reputation Level)dykebert User rank is Sergeant Major (2000 - 5000 Reputation Level)dykebert User rank is Sergeant Major (2000 - 5000 Reputation Level)dykebert User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 18 h 7 m 11 sec
Reputation Power: 21
Justification (right, left, or center) are display properties and have little to do with the data itself. The exception being needing to left pad a number or string due to fixed width fields in a .txt file.

Tables are for storing data and queries are for retrieving data. Forms and reports are used to display data.

What you want to do is very doable in a form or report becuase that is what they are for, displaying data. You can view the data in a table, but that is not their (tables) primary function.

By padding the field with spaces you've already 'right justified' the data for a fixed field length.

If you want a display that can be right justified and looks like a table view I'd suggest you create a datasheet form and view that data through it.

Reply With Quote
  #12  
Old May 15th, 2008, 08:36 AM
mcianfrani mcianfrani is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jan 2007
Posts: 19 mcianfrani User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 6 h 21 m 57 sec
Reputation Power: 0
I can export the datasheet form to a .txt file and it'll keep the formatting?

Reply With Quote
  #13  
Old May 15th, 2008, 09:04 AM
sbenj69's Avatar
sbenj69 sbenj69 is offline
Dark Sonic Apprentice :D
Click here for more information
 
Join Date: Feb 2007
Location: Redneck part of Illinois
Posts: 1,454 sbenj69 User rank is General 2nd Grade (Above 100000 Reputation Level)sbenj69 User rank is General 2nd Grade (Above 100000 Reputation Level)sbenj69 User rank is General 2nd Grade (Above 100000 Reputation Level)sbenj69 User rank is General 2nd Grade (Above 100000 Reputation Level)sbenj69 User rank is General 2nd Grade (Above 100000 Reputation Level)sbenj69 User rank is General 2nd Grade (Above 100000 Reputation Level)sbenj69 User rank is General 2nd Grade (Above 100000 Reputation Level)sbenj69 User rank is General 2nd Grade (Above 100000 Reputation Level)sbenj69 User rank is General 2nd Grade (Above 100000 Reputation Level)sbenj69 User rank is General 2nd Grade (Above 100000 Reputation Level)sbenj69 User rank is General 2nd Grade (Above 100000 Reputation Level)sbenj69 User rank is General 2nd Grade (Above 100000 Reputation Level)sbenj69 User rank is General 2nd Grade (Above 100000 Reputation Level)sbenj69 User rank is General 2nd Grade (Above 100000 Reputation Level)sbenj69 User rank is General 2nd Grade (Above 100000 Reputation Level)sbenj69 User rank is General 2nd Grade (Above 100000 Reputation Level)  Folding Points: 188372 Folding Title: Super Ultimate Folder - Level 1Folding Points: 188372 Folding Title: Super Ultimate Folder - Level 1Folding Points: 188372 Folding Title: Super Ultimate Folder - Level 1Folding Points: 188372 Folding Title: Super Ultimate Folder - Level 1Folding Points: 188372 Folding Title: Super Ultimate Folder - Level 1Folding Points: 188372 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 2 Weeks 5 Days 13 h 38 m 51 sec
Reputation Power: 1077
is the data numbers? If it's only numbers then you can do a val([yourfield]).

Just for your information, queries aren't designed to give your formatted output, so to speak, like forms, reports, or datapages can.

In queries, text is left justified and numbers/dates are right justified. No way around it.

If you want something that looks like a query (datasheet view), create a form using that query with the wizard, choose datasheet type, and then when you go into design view of the form, for each of the fields, go to properties, format tab, text align, and choose right.

Reply With Quote
  #14  
Old May 15th, 2008, 10:05 AM
mcianfrani mcianfrani is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jan 2007
Posts: 19 mcianfrani User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 6 h 21 m 57 sec
Reputation Power: 0
Will it keep the alignment if I export it to a .txt file?

Reply With Quote
  #15  
Old May 15th, 2008, 10:34 AM
sbenj69's Avatar
sbenj69 sbenj69 is offline
Dark Sonic Apprentice :D
Click here for more information
 
Join Date: Feb 2007
Location: Redneck part of Illinois
Posts: 1,454 sbenj69 User rank is General 2nd Grade (Above 100000 Reputation Level)sbenj69 User rank is General 2nd Grade (Above 100000 Reputation Level)sbenj69 User rank is General 2nd Grade (Above 100000 Reputation Level)sbenj69 User rank is General 2nd Grade (Above 100000 Reputation Level)sbenj69 User rank is General 2nd Grade (Above 100000 Reputation Level)sbenj69 User rank is General 2nd Grade (Above 100000 Reputation Level)sbenj69 User rank is General 2nd Grade (Above 100000 Reputation Level)sbenj69 User rank is General 2nd Grade (Above 100000 Reputation Level)sbenj69 User rank is General 2nd Grade (Above 100000 Reputation Level)sbenj69 User rank is General 2nd Grade (Above 100000 Reputation Level)sbenj69 User rank is General 2nd Grade (Above 100000 Reputation Level)sbenj69 User rank is General 2nd Grade (Above 100000 Reputation Level)