Private Sub ListSelections_Click() Dim RS As DAO.Recordset Dim SelectedValue As String Dim varItem As Variant Set RS = CurrentDb.OpenRecordset("Select * from tblClientAssessmentTechniquesUsed where ClientID = " & Me.txtClientID.Value) With RS If .RecordCount = 0 Then MsgBox "This appears to be a new selection which does not already exist in the client table. A new selection is being created." SelectedValue = ListSelections.ItemData(varItem) .AddNew Else MsgBox "This selection already exists and will be edited if you have made changes." .Edit End If SelectedValue = ListSelections.ItemData(varItem) !ClientID = Me.txtClientID !ID = SelectedValue .Update End With End Sub
From novice to tech pro — start learning today.