Please see attached file
Code for that
*********
Option Explicit
Private Const CB_SHOWDROPDOWN As Long = &H14F
Private Const CB_GETDROPPEDSTATE As Long = &H157
Private Drop As Boolean
Private Const CB_FINDSTRING = &H14C
Private Const CB_SELECTSTRING = &H14D
Private Const CB_LIMITTEXT = &H141
Private Const CB_ERR = (-1)
Dim rd As ADODB.connection
Dim cs As ADODB.recordset
Private Sub lan()
Set rd = CreateObject("Adodb.connection")
rd.Provider = "Microsoft.jet.oledb.4.0"
rd.Open App.Path & "\medrar.mdb"
Set cs = New ADODB.recordset
cs.Open "Select lnum from lands", rd, adOpenKeyset, adLockOptimistic
While Not cs.EOF
Combo2.AddItem cs.Fields("lnum")
cs.MoveNext
Wend
cs.Close
Set cs = Nothing
Drop = True
End Sub
Private Sub Combo2_KeyPress(KeyAscii As Integer)
Dim t$, rez&, l&
Combo2.SelText = ""
t$ = Combo2.Text & Chr$(KeyAscii)
rez& = SendMessage(Combo2.hwnd, CB_FINDSTRING, -1, ByVal t$)
If rez& <> CB_ERR Then
l& = Len(t$)
Combo2.Text = Combo2.List(rez&)
Combo2.ListIndex = rez&
KeyAscii = 0
Combo2.SelStart = l&
Combo2.SelLength = Len(Combo2.Text) - l&
End If
Dropdow
End Sub
Private Sub Combo2_LostFocus()
Dim t$, rez&
t$ = Combo2.Text
rez& = SendMessage(Combo2.hwnd, CB_FINDSTRING, -1, ByVal t$)
End Sub
Private Sub Dropdow()
If Drop Then
If SendMessage(Combo2.hwnd, CB_GETDROPPEDSTATE, 0, ByVal 0&) = 0 Then
Call SendMessage(Combo2.hwnd, CB_SHOWDROPDOWN, 1&, 0&)
End If
End If
End Sub
Private Sub Combo2_Click()
Dim cnemployee As New ADODB.connection
Dim rsemployee As New ADODB.recordset
Call connection(cnemployee, App.Path & "\medrar.mdb", "endromida")
Call recordset(rsemployee, cnemployee, "SELECT * FROM lands WHERE lnum ='" & Combo2.Text & "'")
If rsemployee.RecordCount = 0 Then
MsgBox "The record you requested could not be found.", vbExclamation, "Fortune Systems Solutions"
Exit Sub
End If
With rsemployee
txtBlock.Text = .Fields!Pblk
txtPrname.Text = .Fields!PName
txtPrcode.Text = .Fields!pnum
txtSQFL.Text = .Fields!sqf_land
txtcost.Text = .Fields!f_sa_pr
End With
Set cnemployee = Nothing
Set rsemployee = Nothing
End Sub
Private Sub Form_Load()
Call lan
End Sub
******