Go Back   Access World Forums > Microsoft Access Discussion > Reports

 
Reply
 
Thread Tools Rate Thread Display Modes
Old 08-21-2018, 05:10 AM   #1
jeran042
Newly Registered User
 
Join Date: Jun 2017
Posts: 78
Thanks: 20
Thanked 1 Time in 1 Post
jeran042 is on a distinguished road
Textbox position

I have a report with a series of command buttons. One of which outputs the report to a PDF. This works fine.

What I am trying to accomplish is to move the position of the reports title textbox from one position to another, and then back again.

Here is what I have for code:

Code:
Private Sub btnPDF_Click()

'Error handling
On Error GoTo Error_Handler

Dim strFormName     As String
Dim MyPath          As String

strFormName = "Month to Date" & Format(Date, "_mmddyy") & ".pdf"
MyPath = "Y:\Budget process information\EXPORTS\"

'Set position of the Report tile
    Me.txtREPORT_TITLE.Left = 0.0417 'this works perfect, basically aligning it to the left margin
    
DoCmd.OutputTo acOutputReport, "RPT: TEMP_MONTH_TO_DATE_DAILY", acFormatPDF, MyPath + strFormName, True
    
MsgBox " Your Report Has Successfully Run " & _
            vbCrLf & " You can find it at: " & MyPath, vbInformation, "SUCCESS"

'Close report
    'DoCmd.Close acReport, Report.Name

'Reset report title position
    Me.txtREPORT_TITLE.Left = 1.0104 'this does nothing.  Should place it to the right of a image on the report

Error_Handler_Exit:
    Exit Sub

Error_Handler:
    Select Case Err.NUMBER
        Case 2501
            Err.Clear
            Resume Error_Handler_Exit
        Case Else
            MsgBox "Error No. " & Err.NUMBER & vbCrLf & "Description: " & Err.Description, vbExclamation, "Database Error"
            Err.Clear
            Resume Error_Handler_Exit
    End Select

End Sub
The report successfully outputs, and the textbox position on the PDF is correct, but the textbox does not reset when you are seeing it on screen.

I have done a bit of research, and, in my mind at least, this is how you would accomplish this.

What am I doing wrong?
Much appreciated,

jeran042 is offline   Reply With Quote
Old 08-21-2018, 05:13 AM   #2
Gasman
Access newbie
 
Join Date: Sep 2011
Location: Swansea, South Wales,UK
Posts: 2,289
Thanks: 290
Thanked 348 Times in 333 Posts
Gasman has a spectacular aura about Gasman has a spectacular aura about
Re: Textbox position

Would you not need a Refresh ?


Edit: Ignore please, not available in a report.
__________________
Access novice. Sometimes trying to give something back.
Access 2007

Last edited by Gasman; 08-21-2018 at 05:19 AM.
Gasman is offline   Reply With Quote
Old 08-21-2018, 05:18 AM   #3
Minty
AWF VIP
 
Minty's Avatar
 
Join Date: Jul 2013
Location: UK - Wiltshire
Posts: 5,540
Thanks: 133
Thanked 1,495 Times in 1,467 Posts
Minty has a spectacular aura about Minty has a spectacular aura about Minty has a spectacular aura about
Re: Textbox position

You've closed the report before moving the textbox.
I'm surprised you don't get an object not found error.

Actually thinking it through, closing the object probably stops all the code after that from running as it's no longer there.

Even if it did work, you would have to reload the report for you to "see" the changes you made.

A better route (IMHO) would be to duplicate your image in the two desired positions, and simply make the relevant one visible based on whatever your criteria are.

__________________
If we have helped please add to our reputation - click the scales symbol on the left, tick 'I approve' and leave a comment.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Minty is offline   Reply With Quote
Old 08-21-2018, 05:20 AM   #4
jeran042
Newly Registered User
 
Join Date: Jun 2017
Posts: 78
Thanks: 20
Thanked 1 Time in 1 Post
jeran042 is on a distinguished road
Re: Textbox position

Quote:
Originally Posted by Minty View Post
You've closed the report before moving the textbox.
I'm surprised you don't get an object not found error.

Actually thinking it through, closing the object probably stops all the code after that from running as it's no longer there.

Even if it did work, you would have to reload the report for you to "see" the changes you made.

A better route (IMHO) would be to duplicate your image in the two desired positions, and simply make the relevant one visible based on whatever your criteria are.


That line is commented out
jeran042 is offline   Reply With Quote
Old 08-21-2018, 06:02 AM   #5
Minty
AWF VIP
 
Minty's Avatar
 
Join Date: Jul 2013
Location: UK - Wiltshire
Posts: 5,540
Thanks: 133
Thanked 1,495 Times in 1,467 Posts
Minty has a spectacular aura about Minty has a spectacular aura about Minty has a spectacular aura about
Re: Textbox position

Quote:
Originally Posted by jeran042 View Post
That line is commented out
So it is, I missed that.

My comment about the reloading still apply, a report isn't dynamic like a form, and refresh isn't available.
__________________
If we have helped please add to our reputation - click the scales symbol on the left, tick 'I approve' and leave a comment.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Minty is offline   Reply With Quote
Old 08-21-2018, 06:10 AM   #6
Gasman
Access newbie
 
Join Date: Sep 2011
Location: Swansea, South Wales,UK
Posts: 2,289
Thanks: 290
Thanked 348 Times in 333 Posts
Gasman has a spectacular aura about Gasman has a spectacular aura about
Re: Textbox position

You need to specify location in in twips ?
That worked for me


Code:
Private Sub Command16_Click()
'Error handling
On Error GoTo Error_Handler

Dim strFormName     As String, strReport As String

Dim MyPath          As String

strFormName = "GMPdata - " & Format(Date, "_mmddyy") & ".pdf"
strReport = "GMPData"
MyPath = "c:\Temp\"

'Set position of the Report tile
    Me.Label13.Left = 1000 'this works perfect, basically aligning it to the left margin
    
DoCmd.OutputTo acOutputReport, strReport, acFormatPDF, MyPath + strFormName, True
    
MsgBox " Your Report Has Successfully Run " & _
            vbCrLf & " You can find it at: " & MyPath, vbInformation, "SUCCESS"

'Close report
    'DoCmd.Close acReport, Report.Name

'Reset report title position
    Me.Label13.Left = 2000 'this does nothing.  Should place it to the right of a image on the report
    
Error_Handler_Exit:
    Exit Sub

Error_Handler:
    Select Case Err.Number
        Case 2501
            Err.Clear
            Resume Error_Handler_Exit
        Case Else
            MsgBox "Error No. " & Err.Number & vbCrLf & "Description: " & Err.Description, vbExclamation, "Database Error"
            Err.Clear
            Resume Error_Handler_Exit
    End Select

End Sub
__________________
Access novice. Sometimes trying to give something back.
Access 2007
Gasman is offline   Reply With Quote
The Following User Says Thank You to Gasman For This Useful Post:
jeran042 (08-21-2018)
Old 08-21-2018, 06:38 AM   #7
jeran042
Newly Registered User
 
Join Date: Jun 2017
Posts: 78
Thanks: 20
Thanked 1 Time in 1 Post
jeran042 is on a distinguished road
Re: Textbox position

Gasman,

That was it exactly,
Thank you for your help!!

jeran042 is offline   Reply With Quote
Old 08-21-2018, 06:49 AM   #8
Gasman
Access newbie
 
Join Date: Sep 2011
Location: Swansea, South Wales,UK
Posts: 2,289
Thanks: 290
Thanked 348 Times in 333 Posts
Gasman has a spectacular aura about Gasman has a spectacular aura about
Re: Textbox position

Quote:
Originally Posted by jeran042 View Post
Gasman,

That was it exactly,
Thank you for your help!!
So it never really moved at all?

Took me 20 mins to work it out though.
Perhaps something I can use in the future, which is why I played around with it.
__________________
Access novice. Sometimes trying to give something back.
Access 2007
Gasman is offline   Reply With Quote
Old 08-21-2018, 07:35 AM   #9
Minty
AWF VIP
 
Minty's Avatar
 
Join Date: Jul 2013
Location: UK - Wiltshire
Posts: 5,540
Thanks: 133
Thanked 1,495 Times in 1,467 Posts
Minty has a spectacular aura about Minty has a spectacular aura about Minty has a spectacular aura about
Re: Textbox position

Just another thought - If you don't save the reports design on closing the resetting of the label position should be unnecessary ?

__________________
If we have helped please add to our reputation - click the scales symbol on the left, tick 'I approve' and leave a comment.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Minty is offline   Reply With Quote
Reply

Tags
report , text alignment , vba

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Help, How to keep the cursor position in a textbox Louislam Modules & VBA 4 02-13-2014 04:57 PM
Curser Position in Textbox Glue Forms 2 12-14-2012 08:58 PM
Cursor Position at end of textbox craigachan Forms 6 01-09-2010 08:52 AM
Create & Position Textbox in Word modest Modules & VBA 1 06-09-2005 08:49 AM
put cursor on position in textbox VBA ingrid Modules & VBA 7 08-27-2003 06:54 AM




All times are GMT -8. The time now is 02:50 PM.


Microsoft Access Help
General
Tables
Queries
Forms
Reports
Macros
Modules & VBA
Theory & Practice
Access FAQs
Code Repository
Sample Databases
Video Tutorials

Sponsored Links

How to advertise

Media Kit


Powered by vBulletin®
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
(c) copyright 2017 Access World