Thank you all for your advice. Finally i used the Dlookup to make this work. I built an expression in the code builder with the help of an Access Microsoft representative.
The code goes like this:
Private Sub CODE_LostFocus()
Dim x As Variant
x= DLookup("[LASTNAME]", "COMPREF", "[CODENUM] =" & Forms![ENTER NEW COMPS]!CODE)
Me.Text24 = x
End Sub
In this instance, LASTNAME is a field name, COMPREF is a table, CODENUM is a field name, ENTER NEW COMPS is a table name, CODE is a field name and Text24 is the label of the text box to be filled.
If i understand this correctly it takes the CODENUM you enter and as soon as that field loses focus it searches the table COMPREF, for the name that matches the codenum, then it puts the name found into the form ENTER NEW COMPS in the CODE field. Specifically into the Text24 text box.
I hope this help anyone trying to do this and if not please e-mail me.
Dfitz92@aol.com