Results 1 to 8 of 8
  1. #1
    5 Star Lounger
    Join Date
    Jul 2001
    Location
    NJ, USA
    Posts
    617
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Adding a new record (Access03)

    I have a form that has a list control that I pick an open class. Once I click the Register button it is suppose to create a new record in the
    subfrmRegistration. The problem is that if the person has registered for a previous class that record is displayed and that record it changed to
    reflect the class number. How do I get the new record to append to the table instead of amending any existing records? I tried making the subfrm a data
    entry only and that didn't work. The record showed in the base table but not on the subform so you don't know if the thing was added unless you go deep
    into the database, which I don't want others to do.

    Thank you in advance.

    Fay

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

    Re: Adding a new record (Access03)

    What is the code behind the Register button?

  3. #3
    5 Star Lounger
    Join Date
    Jul 2001
    Location
    NJ, USA
    Posts
    617
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Adding a new record (Access03)

    Hi Hans. Here is the code.

    Private Sub cmdRegistered_Click()
    Me!subfrmRegistrationLearner!txtClassNumber = Me.lstPicker
    Me.Requery
    End Sub

    Thank you. Fay

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

    Re: Adding a new record (Access03)

    Well, that code sets the value of txtClassNumber in the current record in the subform, it does not create a new record. Try this:

    Private Sub cmdRegistered_Click()
    Me!subfrmRegistrationLearner.SetFocus
    RunCommand acCmdRecordsGoToNew
    Me!subfrmRegistrationLearner!txtClassNumber = Me.lstPicker
    Me.Requery
    End Sub

    (I'm not sure why you need Me.Requery)

  5. #5
    5 Star Lounger
    Join Date
    Jul 2001
    Location
    NJ, USA
    Posts
    617
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Adding a new record (Access03)

    Thank you Hans that worked. Fay

  6. #6
    5 Star Lounger
    Join Date
    Jul 2001
    Location
    NJ, USA
    Posts
    617
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Adding a new record (Access03)

    Okay I jumped the gun. It worked once then I get the following message
    Microsoft Visual Basic error
    Error 2046
    The command or action 'RecordGoToNew' isn't available now.

    I havent found any help to address this. Any ideas.

    Thank you Fay

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

    Re: Adding a new record (Access03)

    You will get that error if the subform is already on a new record. The following version tests for this:

    Private Sub cmdRegistered_Click()
    Me!subfrmRegistrationLearner.SetFocus
    If Me!subfrmRegistrationLearner.Form.NewRecord = False Then
    RunCommand acCmdRecordsGoToNew
    End If
    Me!subfrmRegistrationLearner!txtClassNumber = Me.lstPicker
    Me.Requery
    End Sub

  8. #8
    5 Star Lounger
    Join Date
    Jul 2001
    Location
    NJ, USA
    Posts
    617
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Adding a new record (Access03)

    Okay, that worked. Thanks for taking me into an area I haven't gone before. Fay

Posting Permissions

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