Results 1 to 14 of 14
  1. #1
    Lounger
    Join Date
    Apr 2001
    Location
    Lakeland, Florida 33805-9595
    Posts
    47
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Northwind Orders form button to Add New Product (Access 2000)

    In Access 2000 Northwind.mdb I have a "Enter new Product" Button on Orders Form and on the "New Product" Form (based on qryProducts) I have a "Save" and "Close Form" button.
    When back to Orders Form and in the Subform the New Product does not show up.
    I have tried to add code to both buttons on the "New Products" Form like DoCmd.Requery, DoCmd.Save acQuery, "qryProducts".
    Neither works.
    Any suggestions.
    plang99@yahoo.com

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

    Re: Northwind Orders form button to Add New Product (Access 2000)

    Does your subform have a combobox on it for the products? If so, try requerying the combobox itself.
    Charlotte

  3. #3
    Lounger
    Join Date
    Apr 2001
    Location
    Lakeland, Florida 33805-9595
    Posts
    47
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Northwind Orders form button to Add New Product (Access 2000)

    Charlotte,
    The subform like the one in Northwind has a combo box for the ProductID.
    I tired code to requerry here but it goes into a loop and cannot do anything else.
    Paul

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

    Re: Northwind Orders form button to Add New Product (Access 2000)

    You'll have to post the code you're trying to use. I can't even begin to imagine what you're doing otherwise.
    Charlotte

  5. #5
    Lounger
    Join Date
    Apr 2001
    Location
    Lakeland, Florida 33805-9595
    Posts
    47
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Northwind Orders form button to Add New Product (Access 2000)

    Charlotte,

    Because of the Hurricane, I will not be home until Monday. No electricity, etc.

    Paul

  6. #6
    Lounger
    Join Date
    Apr 2001
    Location
    Lakeland, Florida 33805-9595
    Posts
    47
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Northwind Orders form button to Add New Product (Access 2000)

    Charlotte,
    I remember from 1-2-3 and Excel that F9 did recalculation and that worked. Now the code reads:

    Private Sub ProductID_GotFocus()
    DoCmd.DoMenuItem acFormBar, acRecordsMenu, acRefresh, , acMenuVer70
    Me!ProductID.Dropdown
    End Sub

    Paul

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

    Re: Northwind Orders form button to Add New Product (Access 2000)

    Well, that's one way to do it, but refresh applies to the recordset, not the form or control. To update a form or control from code, you use something like Me!ProductID.Requery for the control or Me.Requery for the entire form. Since a subform is a special kind of control, you would use Me!SubformControl.Requery to requery the subform, substituting the name of your control for "SubformControl" in the expression I posted.
    Charlotte

  8. #8
    Lounger
    Join Date
    Apr 2001
    Location
    Lakeland, Florida 33805-9595
    Posts
    47
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Northwind Orders form button to Add New Product (Access 2000)

    I tried:
    Private Sub ProductID_GotFocus()
    'DoCmd.DoMenuItem acFormBar, acRecordsMenu, acRefresh, , acMenuVer70
    Me!ProductID.Requery
    Me!ProductID.Dropdown
    End Sub

    This worked. I like it better as the code is shorter. User just cannot be on the blank line item when they go to "Add New Product". But if they are the F9 works to see the new item.

    The Me.Requery put it in a loop.
    Thanks

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

    Re: Northwind Orders form button to Add New Product (Access 2000)

    <hr>The Me.Requery put it in a loop.<hr>
    Is the control the first one in the tab order? That would cause the loop. The requery statements should normally be in the routine that causes the list to change, not in the GotFocus event of the combobox. However, requerying the form also returns to the first record in the recordset, so you have to store the key for that record in a variable and then do a find to get back to it after the requery.
    Charlotte

  10. #10
    Lounger
    Join Date
    Apr 2001
    Location
    Lakeland, Florida 33805-9595
    Posts
    47
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Northwind Orders form button to Add New Product (Access 2000)

    Charlotte,

    The control if the first one. I have put code on the Add New Products form's the Save and the Close buttong also. So it does work OK and does not slow it up as there are under 1000 products.

    Thanks.

    Paul

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

    Re: Northwind Orders form button to Add New Product (Access 2000)

    Since I'm not looking at the Northwind database, I'm not sure what you're referring to. If the Add New Product form is a separate form, then you only need the code to requery a control on another form in the Save button's code. You don't need it at all in the GotFocus event of the control.
    Charlotte

  12. #12
    Lounger
    Join Date
    Apr 2001
    Location
    Lakeland, Florida 33805-9595
    Posts
    47
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Northwind Orders form button to Add New Product (Access 2000)

    I see what you mean. I would need to Requery "Order Details Extended" that the subform is based on. I'' try that.

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

    Re: Northwind Orders form button to Add New Product (Access 2000)

    No, you requery the subform itself.
    Charlotte

  14. #14
    Lounger
    Join Date
    Apr 2001
    Location
    Lakeland, Florida 33805-9595
    Posts
    47
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Northwind Orders form button to Add New Product (Access 2000)

    Yes, I found that out. It is working now.

Posting Permissions

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