B
Bob Matthews
Hi John
Step 3: In the combo's Change event procedure, you could also use a single
line. The code below illustrates how to do a little more, blocking initial
spaces, and forcing "Mt " to "Mount ":
Dim cbo As ComboBox ' Suburb combo.
Dim sText As String ' Text property of combo.
Set cbo = Me.Suburb
sText = cbo.Text
Select Case sText
Case " " ' Remove initial space
cbo = Null
Case "MT " ' Change "Mt " to "Mount ".
cbo = "MOUNT "
cbo.SelStart = 6
Call ReloadSuburb(sText)
Case Else ' Reload RowSource data.
Call ReloadSuburb(sText)
End Select
Set cbo = Nothing
Step 4: To assign the State and Postcode, add this code to the combo's
AfterUpdate event procedure:
Dim cbo As ComboBox
Set cbo = Me.Suburb
If Not IsNull(cbo.Value) Then
If cbo.Value = cbo.Column(0) Then
If Len(cbo.Column(1)) > 0 Then
Me.State = cbo.Column(1)
End If
If Len(cbo.Column(2)) > 0 Then
Me.Postcode = cbo.Column(2)
End If
Else
Me.Postcode = Null
End If
End If
Set cbo = NothingBob M"John W. Vinson"
Step 3: In the combo's Change event procedure, you could also use a single
line. The code below illustrates how to do a little more, blocking initial
spaces, and forcing "Mt " to "Mount ":
Dim cbo As ComboBox ' Suburb combo.
Dim sText As String ' Text property of combo.
Set cbo = Me.Suburb
sText = cbo.Text
Select Case sText
Case " " ' Remove initial space
cbo = Null
Case "MT " ' Change "Mt " to "Mount ".
cbo = "MOUNT "
cbo.SelStart = 6
Call ReloadSuburb(sText)
Case Else ' Reload RowSource data.
Call ReloadSuburb(sText)
End Select
Set cbo = Nothing
Step 4: To assign the State and Postcode, add this code to the combo's
AfterUpdate event procedure:
Dim cbo As ComboBox
Set cbo = Me.Suburb
If Not IsNull(cbo.Value) Then
If cbo.Value = cbo.Column(0) Then
If Len(cbo.Column(1)) > 0 Then
Me.State = cbo.Column(1)
End If
If Len(cbo.Column(2)) > 0 Then
Me.Postcode = cbo.Column(2)
End If
Else
Me.Postcode = Null
End If
End If
Set cbo = NothingBob M"John W. Vinson"
Thanks John
I have added those two lines [I did think that they appeared
automatically,
which led me to believe I was doing something wrong]
Current state of Affairs:
I have loaded up the Australian Postcode Table
I open the Form
I enter "Ni" and the dropdown box shows one line which is from the code in
Step 3
viz. SELECT Suburb, State, Postcode FROM Postcodes WHERE (False)
I enter a further letter "Nig" and an additional line appears
State Postcode
Rather than my digging through multiple posts and hundreds of lines of
(possibly long obsolete) code, could you post the actual code for the
combo's
event?