Textbox position (1 Viewer)

jeran042

Registered User.
Local time
Today, 10:20
Joined
Jun 26, 2017
Messages
127
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,
 

Gasman

Enthusiastic Amateur
Local time
Today, 17:20
Joined
Sep 21, 2011
Messages
14,044
Would you not need a Refresh ?


Edit: Ignore please, not available in a report. :eek:
 
Last edited:

Minty

AWF VIP
Local time
Today, 17:20
Joined
Jul 26, 2013
Messages
10,355
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.
 

jeran042

Registered User.
Local time
Today, 10:20
Joined
Jun 26, 2017
Messages
127
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
 

Minty

AWF VIP
Local time
Today, 17:20
Joined
Jul 26, 2013
Messages
10,355
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.
 

Gasman

Enthusiastic Amateur
Local time
Today, 17:20
Joined
Sep 21, 2011
Messages
14,044
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
 

jeran042

Registered User.
Local time
Today, 10:20
Joined
Jun 26, 2017
Messages
127
Gasman,

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

Gasman

Enthusiastic Amateur
Local time
Today, 17:20
Joined
Sep 21, 2011
Messages
14,044
Gasman,

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

So it never really moved at all? :D

Took me 20 mins to work it out though. :banghead:
Perhaps something I can use in the future, which is why I played around with it.
 

Minty

AWF VIP
Local time
Today, 17:20
Joined
Jul 26, 2013
Messages
10,355
Just another thought - If you don't save the reports design on closing the resetting of the label position should be unnecessary ?
 

Users who are viewing this thread

Top Bottom