طيب هذا الكود يحتاج الى تعديل ممكن تطلع عليه
1- كود الوحدة النمطية
Option Compare Database
Option Explicit
Public conn As New ADODB.Connection
Public rs As New Recordset
Dim bExit As Boolean
Public Sub Egy(sTextBox As TextBox, sTable As String, sField As String, Optional sDBPass As String)
On Error Resume Next
Dim lLen As Long, strSQL As String
If bExit = True Or sTextBox = "" Then Exit Sub
lLen = Len(sTextBox)
strSQL = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\Data.mdb;Persist Security Info=False"
If conn.State <> 1 Then conn.Open strSQL
strSQL = "SELECT * FROM " & sTable & " WHERE " & sField & " LIKE '" & sTextBox & "%'"
If rs.State = 1 Then rs.Close
rs.Open strSQL, conn, adOpenKeyset, adLockReadOnly
If rs.EOF And rs.BOF Then Exit Sub
sTextBox.Text = rs(sField)
If sTextBox.SelText = "" Then
sTextBox.SelStart = lLen
Else
sTextBox.SelStart = InStr(sTextBox.Text, sTextBox.SelText)
End If
sTextBox.SelLength = Len(sTextBox.Text)
End Sub
ومن ثم هذا الكود في النموذج
Private Sub text76_Change()
Egy Text1, "IETEM_NEM", "ITEM_NEM"
End Sub
Egy اسم الوظيفية في الوحدة النمطية
Text1 هو اسم مربع النص
IETEM_NEM اسم الجدول
والاخيرة اسم الحقل