How to open a template form, name it and save it with VBA

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • troy_lee@comcast.net

    How to open a template form, name it and save it with VBA

    Let's say I have a template form named Form1. I have two text fields
    named Month and Year.

    Using an event procedure from another form, I want to:

    1) Open the template form
    2) Name the form based on the concatenated entries of the two text
    fields
    3) Save the form and leave it open

    Thanks in advance.

    Troy Lee
  • Salad

    #2
    Re: How to open a template form, name it and save it with VBA

    troy_lee@comcas t.net wrote:
    Let's say I have a template form named Form1. I have two text fields
    named Month and Year.
    >
    Using an event procedure from another form, I want to:
    >
    1) Open the template form
    2) Name the form based on the concatenated entries of the two text
    fields
    3) Save the form and leave it open
    >
    Thanks in advance.
    >
    Troy Lee
    I have a difficult time understanding your situation. Do you open a
    form, enter data into two fields, and then expect to rename itself to
    something contained in its textboxes? I don't see how one can rename a
    form that it open. Do you?

    I'll offer a couple of pointers.
    Rename an object
    DoCmd.Rename "MyNewFormName" , acForm, "MyOldFormN ame"
    Copy an existing object
    DoCmd.CopyObjec t, "MyNewFormName" ", acFrom, "MyOldFormN ame"

    My Rarotonga


    Comment

    • troy_lee@comcast.net

      #3
      Re: How to open a template form, name it and save it with VBA

      On Jun 3, 11:31 am, Salad <o...@vinegar.c omwrote:
      troy_...@comcas t.net wrote:
      Let's say I have a template form named Form1. I have two text fields
      named Month and Year.
      >
      Using an event procedure from another form, I want to:
      >
      1) Open the template form
      2) Name the form based on the concatenated entries of the two text
      fields
      3) Save the form and leave it open
      >
      Thanks in advance.
      >
      Troy Lee
      >
      I have a difficult time understanding your situation. Do you open a
      form, enter data into two fields, and then expect to rename itself to
      something contained in its textboxes? I don't see how one can rename a
      form that it open. Do you?
      >
      I'll offer a couple of pointers.
      Rename an object
      DoCmd.Rename "MyNewFormName" , acForm, "MyOldFormN ame"
      Copy an existing object
      DoCmd.CopyObjec t, "MyNewFormName" ", acFrom, "MyOldFormN ame"
      >
      My Rarotongahttp://www.youtube.com/watch?v=lNQ1Arc 9Nik
      For anyone with a similar issue, here is the code I came up with. It
      works well. This is coming from what I call the initiation form. This
      collects a few key pieces of information. A template form is copied
      and renamed to the variable strTitle.

      Private Sub cmdCreateScorec ard_Click()
      Dim strTitle As String

      strTitle = Me!cboSelectMon th & " " & Me!txtEnterYear

      DoCmd.CopyObjec t , strTitle, acForm, "Copy of
      frmSummaryScore cardTemplate"
      DoCmd.OpenForm strTitle, , , , acFormEdit

      End Sub

      Comment

      Working...