Formatting problem when exporting from Access 2007 to word doc (1 Viewer)

alex_117058

New member
Local time
Today, 06:26
Joined
Jan 9, 2012
Messages
5
Hello everyone,
I'm very new to access and computer programming in general, but thanks to sites such as this, I've learned quite a bit. I'm managing a database for a client and for the most part it does exactly what I want it to do. The only issue is that when I export a report in access 2007 to word, I get repeating labels in the word document. I have the "hide duplicates" function on in the report, so the only labels that I see on the report are unique. Therefore, I should not be seeing duplicates in the doc. An example is this:

Access 2007 report
Ch1
Part 1
Part 2
Part 3

Ch2
Part 4
Part 5
Part 6

Ch3
Part 7
Part 8
Part 9

etc.

However, in Word:
Ch1
Part 1
Part 2
Part 3

Ch2
Part 4
Part 5
Part 6

Ch2
Part 7
Part 8
Part 9
etc.

Everything is correct about the report except the underlined header being repeated for every category (each category is different from each other). Right now, I'm thinking it's a word program glitch? I've tried to export in pdf and all the underlined headers come out correct. Unfortunately, I need the report to be exported into word for further manipulation. Thanks for any help!

Also, as a follow up to the post, I'm currently using a macro to export from access to word. I'm aware of the export function in the external data tab on the ribbon, but the client likes to have things as simple and automated as possible, so a button on the report would be much more preferable than having to run an a saved export function each time. Thanks again.
 
Last edited:

vbaInet

AWF VIP
Local time
Today, 13:26
Joined
Jan 22, 2010
Messages
26,374
If it's exporting correctly to PDF and it displays correctly, then it could be a coding issue or a problem with Word. Do you have code that sets the value of the underlined category?

What happens if you export to Excel?
 

alex_117058

New member
Local time
Today, 06:26
Joined
Jan 9, 2012
Messages
5
I have the value of the underlined category coming directly from a form. The whole report is generated from a single form. I've exported it into the .rtf, .txt, and excel formats and I've gotten the same issue as before. Another thing is that since I've been using Access, there are times when the macros I create act "weird", as in i'll have two macros in the same form. One will open a report associated with the form and the other will open a different form. However, I'll try to test it after closing all relevant forms and both macros will open the same report or the same form. I've found that when I use vba these issues don't happen. Do you think this could be another instance where vba would be better? Thanks! -- Alex
 

vbaInet

AWF VIP
Local time
Today, 13:26
Joined
Jan 22, 2010
Messages
26,374
Macros aren't that bad really. It's just how you write the sequences and the actions that follow. I prefer VBA anyway.

Can you convert the macro to VBA and post it here.

Also, what's in the Control Source of that textbox on the form?
 

alex_117058

New member
Local time
Today, 06:26
Joined
Jan 9, 2012
Messages
5
Haha, I guess I have bad luck then. Most of the macros I'm using are just one action macros. Namely the "outputto" function. As for using vba, I'm not entirely sure how to write the code needed to export from report to word. Also, it turns out that the report is actually getting all the information from a query. Thanks again.
 

vbaInet

AWF VIP
Local time
Today, 13:26
Joined
Jan 22, 2010
Messages
26,374
Open the query in design view and look around, you should find a menu or button that will allow you to convert a macro to VBA code. Post that.

What I meant is, a textbox has a Control Source property which is basically the text you see in the textbox when the form is in design view. What's written in those textboxes when the form is in design view?
 

alex_117058

New member
Local time
Today, 06:26
Joined
Jan 9, 2012
Messages
5
The vba code for the macro:
Private Sub Command34_Click()
On Error GoTo Command34_Click_Err

DoCmd.OutputTo acOutputReport, "BookChapters", "RichTextFormat(*.rtf)", "", True, "", 0, acExportQualityPrint

Command34_Click_Exit:
Exit Sub
Command34_Click_Err:
MsgBox Error$
Resume Command34_Click_Exit
End Sub

As for the control source, it says "ChapterNumber" when I view it in design view.

Thanks again!
 

vbaInet

AWF VIP
Local time
Today, 13:26
Joined
Jan 22, 2010
Messages
26,374
I don't see anything wrong with it. What if you take out the 0?
 

alex_117058

New member
Local time
Today, 06:26
Joined
Jan 9, 2012
Messages
5
Same issue. I might have to tell my client to do a manual export instead of using a macro. It appears that word is having a programming issue? I'm not sure what to do about that other then to not use macros for specific reports now..
 

vbaInet

AWF VIP
Local time
Today, 13:26
Joined
Jan 22, 2010
Messages
26,374
Can you upload the table and report you're having problems with? I don't need sensitive data.
 

Users who are viewing this thread

Top Bottom