Results 1 to 2 of 2
  1. #1
    cmb is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Sep 2014
    Posts
    11

    Combo box is updating all fields in Sub Form

    Hi there,

    I have a sub form that adds and displays appointments related to an order. The form has two combo boxes, cboVenderTypeID and cboVenderID and a date picker. There is a 3rd combo box on the parent form called OrderNode. The contents the cboVenderID combo box are filtered by the selections made in cboVenderTypeID and VenderID comb boxes. This works fine and adds the appropriate appointment to tblAppoints. The problem is when I try to add an appointment with of a different type (different value in cboVenderTypeID) all the values in the existing appointments change to the latest value selected in cboVenderTypeID. Any help with my code would be greatly appreciated! Many thanks in advance!

    Private Sub cboVenderTypeID_AfterUpdate()

    Dim strSQL As String
    Dim db As DAO.Database
    Dim rs As DAO.Recordset

    If Me.cboVenderTypeID = 4 Then

    strSQL = "SELECT tblVenders.VenderID, tblVenders.VenderFullName, tblVenders.VenderTypeID " & _
    "FROM tblNodes " & _
    "INNER JOIN tblVenders " & _
    "ON tblNodes.NodeID = tblVenders.NodeID " & _
    "WHERE (((tblVenders.VenderTypeID)=" & Me.[cboVenderTypeID] & ")) " & _
    "ORDER BY tblVenders.VenderFullName;"

    Else

    strSQL = "SELECT tblVenders.VenderID, tblVenders.VenderFullName, tblVenders.VenderTypeID, tblNodes.NodeID " & _
    "FROM tblNodes " & _
    "INNER JOIN tblVenders " & _
    "ON tblNodes.NodeID = tblVenders.NodeID " & _
    "WHERE (((tblVenders.VenderTypeID)=" & Me.[cboVenderTypeID] & ") " & _
    "AND ((tblNodes.NodeID)=" & [Forms]![frmNavigation]![NavigationSubform]![OrderNode] & ")) " & _
    "ORDER BY tblVenders.VenderFullName;"

    End If



    Set db = CurrentDb()
    Set rs = db.OpenRecordset(strSQL)

    Me!cboVenderID.RowSource = strSQL
    DoCmd.RunCommand acCmdSaveRecord
    Me!cboVenderID.Requery

    End Sub

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Possibly the combobox ControlSource is bound to wrong field. What is the RecordSource for the form?

    Why run acCmdSaveRecord?

    The recordset code is not needed - remove those lines.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

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

Similar Threads

  1. Replies: 4
    Last Post: 02-05-2014, 04:35 PM
  2. Replies: 8
    Last Post: 08-11-2013, 07:24 PM
  3. Replies: 1
    Last Post: 04-08-2013, 12:04 PM
  4. Replies: 1
    Last Post: 03-27-2012, 05:25 PM
  5. combo not updating form
    By cjamps in forum Forms
    Replies: 5
    Last Post: 04-14-2009, 12:00 PM

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