I Have a table of Entrants with EntantID as the Primary Key, EntrantName and AddressID as a Foreign Key
I Have a table of Addresses with AddressID as the primary Key and Address as text.
I have a list box (LstAddressID) showing all the addresses, so when I add a new Entrant, if the address already exists, I select it from the list box and the AfterUpdate adds the AddressID into the Entrants Table.
No Problem.
If I have to add a new address, I start typing into an unbound field called NewAddress1. Now I am assuming that this really is a new Address, but it may not be, so what I want to happen is the LstAddressID to highlight the first address that partially matches the letters typed into NewAddress1.
I have tried
Expand|Select|Wrap|Line Numbers
- Private Sub NewAddress1_Change()
- 'start where we are in the list and go forward
- Dim iLength As Integer
- Dim irow As Integer
- iLength = Len(Me.NewAddress1.Text)
- If iLength = 0 Then
- Exit Sub
- End If
- For irow = 0 To Me.LstAddressID.ListCount - 1
- Me.LstAddressID.SetFocus
- Me.LstAddressID.ListIndex = irow
- Me.NewAddress1.SetFocus
- If Left(Me.LstAddressID.Column(1), iLength) = Me.NewAddress1 Then
- Exit Sub
- End If
- Next
- End Sub
Any ideas please
Phil