How do I have a combo box limit number of records in form?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a Combo box that pulls information down into a form. I want to limit
the record in the form to the one record selected. Any suggestions?
 
You could use the AfterUpdate event procedure of the unbound combo to set
the RecordSource of the form to a SQL string that contains just that one
record.

Example:

Private Sub cboFilterClientID_AfterUpdate
Dim strSql As String
If Not IsNull(Me.cboFilterClientID Then
If Me.Dirty Then Me.Dirty = False 'Save first.
strSql = "SELECT * FROM tblClient WHERE ClientID = " &
Me.cboFilterClientID & ";"
Me.RecordSource = strSql
End If
End Sub
 
Back
Top