Results 1 to 13 of 13
  1. #1
    Join Date
    Dec 2004
    Posts
    46

    Unanswered: auto change a caption on a report

    Is it possible to change the caption name on a report on opening it?

    Mine is currently called "Transaction summary", but I would like to change it to something like the following:

    "DCX0002-Date-consecutive number"

    The DCX#### is the name of the unique autonumbered field. I'd also like a date stamp on it and then another unique number. Ideally, I'd also be able to automatically log this number on another new table.

    Is this possible? Or are only parts of it possible?

  2. #2
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    Davinder
    Have you actually tried to place some code in the reports "open" or "load" event?
    As suggested before try placing
    me.caption="DCX" & format(now(),"yyyymmmdd_HH:MM")
    HTH

  3. #3
    Join Date
    Dec 2004
    Location
    Netherlands
    Posts
    11
    if there are more records:
    put the title in a textbox and set the controlsource:
    ="DCX" & [autonumbered fieldname]

    else use the reports _Open action to place the title

    the function now() returns the current date and time

    don't know if you know vb code

  4. #4
    Join Date
    Dec 2004
    Posts
    46
    I don't really know VB code at all. I am slowly getting my head around it though. I discovered another bit of code which, when attached to a button, will change the name of the report.

    Private Sub Command103_Click()

    Dim filePDF
    filePDF = Dir(CurrentDb.Name)
    filePDF = Left(filePDF, Len(filePDF) - 4)
    SendKeys filePDF & "~"
    DoCmd.OpenReport "dadcheck® Inclusion letter", acViewNormal

    End Sub

    This only seems to work if the PDF printer is selected as the default printer.

    I will try your method and see what happens. I'm not to keyed up to VB though

  5. #5
    Join Date
    Dec 2003
    Location
    Dallas, TX
    Posts
    1,004
    Hello Tribal and "Welcome to the Forum"
    Hope you find it useful and helpful

    have a nice one,
    BUD

  6. #6
    Join Date
    Dec 2004
    Posts
    46
    healdem

    Genius, it works:

    me.caption="DCX" & format(now(),"yyyymmmdd_HH:MM")


    Only problem is that after DCX it shows the date only and not an autonumber...we're getting there!!!

  7. #7
    Join Date
    Dec 2004
    Posts
    46
    healdem

    Genius, it works:

    me.caption="DCX" & format(now(),"yyyymmmdd_HH:MM")


    Only problem is that after DCX it shows the date only and not an autonumber...we're getting there!!!

    I take it there must be a way of calling up the Unique case_number field and add it into the report name after the me.caption="DCX"

  8. #8
    Join Date
    Dec 2004
    Location
    Netherlands
    Posts
    11
    Private Sub Report_Activate()
    Me.Caption = "DCX" & case_number
    End Sub

    if case_number is the fieldname of the autonumber (otherwise replace 'case_number' with the fieldname)

    and make sure you put it on the reports 'Activate' action (and not on the 'open' action, because that doesn;t work)

  9. #9
    Join Date
    Dec 2004
    Posts
    46
    healdem

    Genius, it works:

    me.caption="DCX" & format(now(),"yyyymmmdd_HH:MM")


    Only problem is that after DCX it shows the date only and not an autonumber...we're getting there!!!

    I take it there must be a way of calling up the Unique case_number field and add it into the report name after the me.caption="DCX"

  10. #10
    Join Date
    Dec 2004
    Posts
    46
    Excellent, major problem is solved now:

    I've modified it slightly to make it look nicer on the eye. The only other minor problem is that the case_number is, as standard a number between 1 and 9999. On all forms etc it's formatted as 0001 or 0025, etc. What sort of code is recommended to put this formatting in?

    me.Caption = "DCX" & Case_number & "Inclusion Letter" & Format(Now(), " yyyy mmmdd_HH:MM")

    Now, heres the the next stage.

    To log this unique "DCX number date time" in a field in another database.

    Would I create a database with autonumbers, etc and then add this as a sort of a hidden field in the report it self. Then instead of the top code with "DCX" & Case_number, etc I would direct it to this hidden field.

  11. #11
    Join Date
    Dec 2004
    Location
    Netherlands
    Posts
    11
    for the number format, you can use this code:

    Dim no
    no = Case_number

    While Len(no) < 4
    no = "0" & no
    Wend

    Me.Caption = "DCX" & no & "Inclusion Letter" & Format(Now(), " yyyy mmmdd_HH:MM")

  12. #12
    Join Date
    Dec 2004
    Posts
    46
    Just about sorted. Here's what I did.

    Dim no
    no = Case_number

    While Len(no) < 4
    no = "0" & no
    Wend

    Me.Caption = "DCX" & no & "Inclusion Letter" & Format(Now(), " yyyy mmmdd_HH:MM")

    The above code is put into an Event Procedure in the Active section of a Report (in the case of this example, the report's called "Inclusion Letter". What the above does is create a title for the report using the Case_number and also a date/time stamp to uniquely identify the correspondence.

    When I preview the report, I print to the MS document image writer.
    It asks where I want to save the file (The file name is the same as the report name noe and I save it as an MDI file) and I save it into the customer's directory. Once I click save, it immediately opens up the file for me to print. PERFECT.

    The only modification I want to do now, it to try and create a unique ID (using the DCX case_number as a prefix) and log this report on to another database. I can't get my head around how to do this though.

    Do I code this unique number which is to be generated and logged into a database, by coding the print/preview button on the form?

    Anyone done anything similar.

  13. #13
    Join Date
    Dec 2004
    Posts
    46
    I found some code which might do what I want. I tried it but it gave an error and im not sure which part to change to correspond to my db.

    Bascially this code is supposed to log when a report is printed.





    insert current time/date in table when report is printed

    --------------------------------------------------------------------------------

    Under the OnOpen event of the report, add code like so:

    Currentdb.Execute "INSERT INTO MyTable (MyDate) VALUES (#"
    & NOW() & "#)"

    hth

    ChrisB
    MCDBA MCSE
    www.MyDBA2000.com

    >-----Original Message-----
    >I have a database that is button driven to maintain stock
    >levels. I need to log when the reorder report is
    printed.
    >Can anyone offer any assistance?
    >Thanks, Billy
    >.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •