Results 1 to 8 of 8
  1. #1
    2 Star Lounger
    Join Date
    Jul 2003
    Posts
    124
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Using Subform to Add Records (Access 2002)

    I have a initial form that opens a subform; a certain amount of the subform's fields are updated from values of the initial form. The remaining fields must be entered by the user via the subform. Certain times user will open the subform but then decide not to create a record by entering information in the remaining fields. Not issue is that since that are fields updated by the initial form the subform creates a record every time it is open. I only want records created when the user enters information in the remaining fields. How do I make it so that the records are not created?

  2. #2
    Super Moderator
    Join Date
    Aug 2001
    Location
    Evergreen, CO, USA
    Posts
    6,624
    Thanks
    3
    Thanked 60 Times in 60 Posts

    Re: Using Subform to Add Records (Access 2002)

    The simplest way is to set the .Default property of the controls that you want to populate automatically. Then no values are added until data is entered into one or more of the fields that the user must specify. If you need more details, please post back.
    Wendell

  3. #3
    2 Star Lounger
    Join Date
    Jul 2003
    Posts
    124
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Using Subform to Add Records (Access 2002)

    On the fields that are populated by the initial form I have the default values set to the initial form; thus when the subform is opened the values are the same as the initial form.

    I'm a bit unclear "Then no values are added until data is entered into one or more of the fields " how you accomplish this. But this is what I'd like to happen. No fields are added until data is entered.

  4. #4
    Super Moderator
    Join Date
    Aug 2001
    Location
    Evergreen, CO, USA
    Posts
    6,624
    Thanks
    3
    Thanked 60 Times in 60 Posts

    Re: Using Subform to Add Records (Access 2002)

    Are you setting the default values in code or are you simply point to controls on the main form? I think you need to actually set the default value property of the controls in VBA when the user enters the subform. Then you shouldn't see any evidence of a new record until one of the user-completed forms is populated with something. And you should be able to cancel the add by pressing ESC twice.
    Wendell

  5. #5
    2 Star Lounger
    Join Date
    Jul 2003
    Posts
    124
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Using Subform to Add Records (Access 2002)

    I'm pointing to the main form in the default value of the subform field; I will use VBA Code to set the value when I do the "DoCmd.OpenForm" in the main from. What code would you suggest?

  6. #6
    Gold Lounger
    Join Date
    Feb 2001
    Location
    Sint Niklaas, Belgium
    Posts
    2,778
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Using Subform to Add Records (Access 2002)

    What <!profile=WendellB>WendellB<!/profile> means is something like this.
    In the On Load Event of the form use some code like :
    Me.MyTextbox.DefaultValue = Forms.InitalForm.TextboxNameYouWantToPass

    Another possibility would be a Cancel Button with the following code :
    If Me.Dirty Then
    Me.Undo
    End If
    DoCmd.Close acForm, Me.Name

    In this case you better set the form to Modal and Popup and disable the close button. You'll also have to create a button for normal closing with saving of the data
    Francois

  7. #7
    2 Star Lounger
    Join Date
    Jul 2003
    Posts
    124
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Using Subform to Add Records (Access 2002)

    What does the Me.Dirty and Me.Undo do?

  8. #8
    Gold Lounger
    Join Date
    Feb 2001
    Location
    Sint Niklaas, Belgium
    Posts
    2,778
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Using Subform to Add Records (Access 2002)

    Me.Dirty is true if anny change has been made in the form. It's the same a the pencil in the record selector. If anny change has been made, the pencil is visible and the form is dirty.
    Me.Undo cancel all the changes made in the form. It's the same as pressing escape twice to cancel changes.
    Francois

Posting Permissions

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