Results 1 to 6 of 6
  1. #1
    5 Star Lounger
    Join Date
    Feb 2001
    Location
    Louisville, Kentucky, USA
    Posts
    605
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Save Form As Report (Access 2000)

    Afternoon All,

    What I'm trying to accomplish is SAVE the FORM as a REPORT.

    I know the form must be closed in order to do so, so I'm using a combo box from another form to pick from a list of available forms. In the AfterUpdate Event the following code runs:

    (In order to make it work I had to have 2 txtboxes on the form, txtFormName and txtRenameForm.)

    Me.txtFormName = Me.cboForms.Column(0)
    Me.txtRenameForm = Me.cboForms.Column(0)

    strOldFrmName = Me.cboForms.Column(0)
    strOldFrmName = Me.txtFormName
    strReportName = "rpt" & Mid(strOldFrmName, 4)
    strNewFormName = Me.txtRenameForm
    strFormName = "frm" & Mid(strNewFormName, 4)

    DoCmd.Rename strReportName, acForm, strOldFrmName
    DoCmd.SelectObject acForm, strReportName, True
    SendKeys "
    Roberta Price <img src=/S/cheers.gif border=0 alt=cheers width=30 height=16>

  2. #2
    Silver Lounger
    Join Date
    Jun 2002
    Location
    Cheadle, Staffordshire
    Posts
    2,177
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Save Form As Report (Access 2000)

    Hello Roberta.

    I'm sorry I don't have an answer for you and I'm sure some-one will.
    I'm only curious as to why you want to rename a form to a report and then back again to it's old form name.?

  3. #3
    5 Star Lounger
    Join Date
    Feb 2001
    Location
    Louisville, Kentucky, USA
    Posts
    605
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Save Form As Report (Access 2000)

    Dave,

    Well...let's see...easiest way, and currently the only way, I know, to create a report from a form in code. Not my preference...but what I came up with at this time.

    The reasoning why I need to is worse explanation than the explanation above.

    Sorry that's all I have right now.
    Roberta Price <img src=/S/cheers.gif border=0 alt=cheers width=30 height=16>

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Save Form As Report (Access 2000)

    I don't know of a really good way to do this; in particular, I don't know how to avoid Sendkeys, but the following is slightly more straightforward than your solution. It doesn't need extra text boxes, and it doesn't rename the form.

    Dim strFormName As String
    Dim strReportName As String
    ' Get out if user didn't select item from list
    If Me.cboForms.ListIndex = -1 Then Exit Sub
    ' Name of form (source)
    strFormName = Me.cboForms
    ' Name of report (target)
    strReportName = "rpt" & Mid(strFormName, 4)
    ' Select form in database window
    DoCmd.SelectObject acForm, strFormName, True
    ' Prepare for SaveAsReport
    SendKeys strReportName & "{Enter}"
    ' Equivalent of Save As Report
    RunCommand acCmdSaveAsReport

  5. #5
    5 Star Lounger
    Join Date
    Feb 2001
    Location
    Louisville, Kentucky, USA
    Posts
    605
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Save Form As Report (Access 2000)

    As always, Thanks Hans.....

    And trust me...you don't want the story as to why I'm doing this. It's uglier than my code was......

    LOL

    Thanks anyway...works great.

    Have a nice day.
    Roberta Price <img src=/S/cheers.gif border=0 alt=cheers width=30 height=16>

  6. #6
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Save Form As Report (Access 2000)

    Alternatively, since forms and reports can have the same name, just save the form to a report with the same name and then rename the report in your code. <img src=/S/shrug.gif border=0 alt=shrug width=39 height=15>
    Charlotte

Posting Permissions

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