#1
|
|||
|
|||
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... |
#2
|
||||
|
||||
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] |
#3
|
|||
|
|||
Ok Thanks Paul
What about enforcing the table to be the full width of the page margins? |
#4
|
||||
|
||||
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] |
#5
|
|||
|
|||
Thanks again Paul, that works however then the longer fields are truncated over 2 lines unfortunately
|
#6
|
||||
|
||||
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] |
#7
|
|||
|
|||
Appreciate all of your help Paul
|
#8
|
|||
|
|||
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 |
#9
|
|||
|
|||
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. |
#10
|
||||
|
||||
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] |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
insert database as field | david_89_ | Mail Merge | 3 | 03-26-2014 06:02 AM |
little database | gsrikanth | Excel | 3 | 06-29-2012 05:23 AM |
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 |