Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 08-10-2014, 11:19 PM
scubadunc scubadunc is offline Database field cell alignment Windows 7 32bit Database field cell alignment Office 2010 32bit
Novice
Database field cell alignment
 
Join Date: Aug 2014
Posts: 6
scubadunc is on a distinguished road
Default Database field cell alignment

Hi gurus

I have a database field pulling in data from an access table. It all works perfectly other than that I would like to right align "subscription.Price", leaving all the other fields left aligned. I already have formatting applied to that field, so wondering if it is a possibility to apply alignment formatting at the same time? See code below...


DATABASE \d "C:\\database\\test.mdb" \c "DSN=MS Access Database; DBQ= C:\\database\\test.mdb;FIL=MS Access" \s " SELECT subscription.PDescription, subscription.PType, subscription.SReserve, subscription.SSection, subscription.SRow, subscription.SNumber, Format(subscription.Price, '$0.00')
FROM subscription
WHERE (((subscription.ConstID)='5444'))"\l"0" \b"124"



Also, is there any way to enforce the outputted table width to the full width of the page margins?

Any help or thoughts appreciated...
Reply With Quote
  #2  
Old 08-11-2014, 12:31 AM
macropod's Avatar
macropod macropod is offline Database field cell alignment Windows 7 32bit Database field cell alignment Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

The cell alignment is controlled entirely by the table format you choose (as set via the \l and \b switches); it's not something you can control at a finer level.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #3  
Old 08-11-2014, 12:37 AM
scubadunc scubadunc is offline Database field cell alignment Windows 7 32bit Database field cell alignment Office 2010 32bit
Novice
Database field cell alignment
 
Join Date: Aug 2014
Posts: 6
scubadunc is on a distinguished road
Default

Ok Thanks Paul

What about enforcing the table to be the full width of the page margins?
Reply With Quote
  #4  
Old 08-11-2014, 12:49 AM
macropod's Avatar
macropod macropod is offline Database field cell alignment Windows 7 32bit Database field cell alignment Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

You can do that by switching off the 'Autofit' parameter. See:
http://office.microsoft.com/en-us/wo...010260104.aspx
For your table, you could change \b"124" to \b"108".
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #5  
Old 08-11-2014, 01:12 AM
scubadunc scubadunc is offline Database field cell alignment Windows 7 32bit Database field cell alignment Office 2010 32bit
Novice
Database field cell alignment
 
Join Date: Aug 2014
Posts: 6
scubadunc is on a distinguished road
Default

Thanks again Paul, that works however then the longer fields are truncated over 2 lines unfortunately
Reply With Quote
  #6  
Old 08-11-2014, 01:32 AM
macropod's Avatar
macropod macropod is offline Database field cell alignment Windows 7 32bit Database field cell alignment Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Somewhat of a balancing act, then. You could use Autofit with a larger font to widen the table, or not use it and reduce the font size to avoid the wrapping.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #7  
Old 08-11-2014, 05:03 PM
scubadunc scubadunc is offline Database field cell alignment Windows 7 32bit Database field cell alignment Office 2010 32bit
Novice
Database field cell alignment
 
Join Date: Aug 2014
Posts: 6
scubadunc is on a distinguished road
Default

Appreciate all of your help Paul
Reply With Quote
  #8  
Old 08-12-2014, 05:32 PM
scubadunc scubadunc is offline Database field cell alignment Windows 7 32bit Database field cell alignment Office 2010 32bit
Novice
Database field cell alignment
 
Join Date: Aug 2014
Posts: 6
scubadunc is on a distinguished road
Default

Hi again Paul

Quick question..Is it possible to do nested database fields?

In my example above, I would like to total the subscription.Price field and nest the following code into the existing so the total aligns with the subscription.Price field in the outputted table.

DATABASE \d "C:\\database\\test.mdb" \c "DSN=MS Access Database; DBQ= C:\\database\\test.mdb;FIL=MS Access" \s " SELECT Format(sum(subscription.Price), '$#,###.00')
FROM subscription
WHERE (((subscription.ConstID)='3992'))"

If that isn't possible, can you think of another way to achieve this? I do have the subscription total calculated in a separate field also. My main concern is aligning the total to the subscription.Price column
Reply With Quote
  #9  
Old 08-12-2014, 08:09 PM
scubadunc scubadunc is offline Database field cell alignment Windows 7 32bit Database field cell alignment Office 2010 32bit
Novice
Database field cell alignment
 
Join Date: Aug 2014
Posts: 6
scubadunc is on a distinguished road
Default

Hi Paul

Found a workaround for the time being...merge to a new document then use a couple of macros to search for a 7 column table...autofit it to window and then right align column 7...Then I just have a separate right aligned total field.

Sub ResizeTable()
Dim oTbl As Table
For Each oTbl In ActiveDocument.Tables
With oTbl
If .Columns.Count = 7 Then
.AutoFitBehavior Behavior:=wdAutoFitWindow
End If
End With
Next oTbl
End Sub

Sub RightAlignColumn7()
Dim oTable As Table
Dim oCol As Column
Dim oCell As Cell
For Each oTable In ActiveDocument.Tables
For Each oCol In oTable.Columns
If oCol.Index = 7 Then
For Each oCell In oCol.Cells
oCell.Range.ParagraphFormat.Alignment _
= wdAlignParagraphRight
Next
End If
Next
Next
End Sub

Last edited by scubadunc; 08-12-2014 at 10:44 PM.
Reply With Quote
  #10  
Old 08-12-2014, 11:02 PM
macropod's Avatar
macropod macropod is offline Database field cell alignment Windows 7 32bit Database field cell alignment Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Hi scubadunc,

No, you can't nest them, either. As per your follow-up post, a macro can be used for reformatting the table but do be aware the reformatting will be lost next time the field updates (e.g. next time you open or print the document).
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Database field cell alignment insert database as field david_89_ Mail Merge 3 03-26-2014 06:02 AM
Database field cell alignment little database gsrikanth Excel 3 06-29-2012 05:23 AM
Database field cell alignment table cell alignment issue gib65 Word 1 06-02-2012 03:03 PM
Vertical Alignment of Text and Label Field jslist@sbcglobal.net Word 0 04-16-2010 12:20 PM
Text Wrapping on Fixed Lines in a Form field/Table cell okrmjr Word Tables 0 10-30-2009 08:52 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 06:44 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft