Not showing combo drop down (1 Viewer)

foxtet

Registered User.
Local time
Today, 04:26
Joined
May 21, 2011
Messages
129
I have used the following codes in shipperID combo box double click event. after adding the record to shipper form save, and close the added record is not available in shipperID combo box drop items.

Private Sub ShipperID_DblClick(Cancel As Integer)
Dim rs As DAO.Recordset
Dim strWhere As String
Const strcTargetForm = "frmShipper"

'Set up to search for the current customer.
If Not IsNull(Me.ShipperID) Then
strWhere = "ShipperID = """ & Me.ShipperID & """"
End If

'Open the editing form.
If Not CurrentProject.AllForms(strcTargetForm).IsLoaded Then
DoCmd.OpenForm strcTargetForm

End If
With Forms(strcTargetForm)

'Save any edits in progress, and make it the active form.

If .Dirty Then .Dirty = False
.SetFocus
If strWhere <> vbNullString Then
'Find the record matching the combo.
Set rs = .RecordsetClone
rs.FindFirst strWhere
If Not rs.NoMatch Then
.Bookmark = rs.Bookmark

End If
Else
'Combo was blank, so go to new record.

RunCommand acCmdRecordsGoToNew

End If

End With

Set rs = Nothing

End Sub

looking for a solution

foxtet
 

sneuberg

AWF VIP
Local time
Yesterday, 17:26
Joined
Oct 17, 2014
Messages
3,506
Hard to see what you are doing but you could try requerying the combo box.

Me. shipperID.Requery at the end.
 

GinaWhipp

AWF VIP
Local time
Yesterday, 20:26
Joined
Jun 21, 2011
Messages
5,901
Why not just use the Not_In_List event? Much easier...

Code:
    Dim strTmp As String
 
        'Get confirmation that this is not just a spelling error.
        strTmp = "Add '" & NewData & "' as a new Shipper?"
        If MsgBox(strTmp, vbYesNo + vbDefaultButton2 + vbQuestion, "Not in list") = vbYes Then
 
            strTmp = "INSERT INTO YOUR TABLE( FIELD IN TABLE) " & _
                "SELECT """ & NewData & """ AS FIELD IN TABLE;"
            DBEngine(0)(0).Execute strTmp, dbFailOnError
 
            'Notify Access about the new record, so it requeries the combo.
            Response = acDataErrAdded
        Else
                DoCmd.RunCommand acCmdUndo
                Response = acDataErrContinue
        End If
 

Users who are viewing this thread

Top Bottom