Results 1 to 4 of 4
  1. #1
    mafu is offline Novice
    Windows 10 Access 2016
    Join Date
    Mar 2020
    Posts
    1

    Need help with two combobox that update with eachother


    Hello, so I am making a stock inventory database and I have a form that I enter products entering our store. I have one combobox that is the cathegory and an other combobox that is products. I want to select a cathegory and depending on that I later have a filtered list on my products combobox. I have managed to do this setting an event to requery after an update on the cathegory combobox. The problem I have is this is a Continuous Form and when I go to the next record and select a new cathegory the product from the previous product gets errased because the list for the product combobox has changed. How can I solve this?

    Thank you

  2. #2
    MadTom's Avatar
    MadTom is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Jun 2018
    Location
    CT and VT
    Posts
    206
    Code:
     Private Sub Form_BeforeUpdate(Cancel As Integer) 'Provide the user with the option to save/undo
    On Error GoTo ErrHandler                       'changes made to the record in the form
            bWasNewRecord = Me.NewRecord
        Call AuditEditBegin("tblParts", "audTmptblParts", "P_ID", Nz(Me.P_ID, 0), bWasNewRecord)
        If MsgBox("Changes may have been made to this form or form maybe blank!." _
            & vbCrLf & vbCrLf & "Do you want to save these changes?" & vbCrLf & "Can't save Blank form!" _
            , vbYesNo, "Changes Made or Blank ...") = vbYes Then
            DoCmd.Save
        Else
            DoCmd.RunCommand acCmdUndo
        End If
    Exit_ErrHandler:
        Exit Sub                                                         ' Exit before error handler.
    ErrHandler:                                                          'jump to on error.
       Call LogError(Err, Error$, "Form_BeforeUpdate_()", P_ID)      'log errors to tLogError table
    Resume Exit_ErrHandler
    End Sub
    I use this Sub in my form.

  3. #3
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 10 Access 2016
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,614
    Quote Originally Posted by mafu View Post
    Hello, so I am making a stock inventory database and I have a form that I enter products entering our store. I have one combobox that is the cathegory and an other combobox that is products. I want to select a cathegory and depending on that I later have a filtered list on my products combobox. I have managed to do this setting an event to requery after an update on the cathegory combobox. The problem I have is this is a Continuous Form and when I go to the next record and select a new cathegory the product from the previous product gets errased because the list for the product combobox has changed. How can I solve this?

    Thank you
    Made sure the query used for you form has the Products table in it so that you can have a textbox on the form bound to the name of the product. Make the textbox a little less wide than the combo box (about 0.450cm). Place the text box on top op the combo box but aligned to the left, so that all that can be seen of the combo box is the ArrowDown bit on the right. In the Got Focus event of the textbox put the following code:
    Code:
    Me.ComboboxName.SetFocus
    In the GotFocus event of the combo box put the following code:
    Code:
    Me.ComboboxName.Requery
    As best as I can remember, this is what I've used in many databases. If you have any problem, post a copy of your db or let me know and I'll post an example of some sort.
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  4. #4
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 10 Access 2016
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,614
    Mafu

    For the sake of completeness I have attached a very basic db to illustrate the method that I suggested in my previous post. I hope it is useful to you. If you need any clarification or have any questions, please post back.

    By the way: Welcome to the forum
    Attached Files Attached Files
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

Please reply to this thread with any new information or opinions.

Similar Threads

  1. How to update a combobox with openForm?
    By Nightcrawler in forum Access
    Replies: 8
    Last Post: 02-20-2018, 08:30 AM
  2. Update Combobox List from another value
    By Joakim N in forum Access
    Replies: 7
    Last Post: 10-12-2016, 11:19 AM
  3. Auto update combobox
    By omegads in forum Access
    Replies: 21
    Last Post: 09-07-2016, 06:20 PM
  4. Replies: 23
    Last Post: 07-10-2014, 12:11 PM
  5. Replies: 6
    Last Post: 07-28-2011, 04:07 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums