howto lookup

R

rufino palacol jr

hi all,

i'm trying to convert my excel database into access. i have a separate
table of companies and its policy no. in my records table, there are two
fields, the policy no and the company name. what will i do if i want access
to automatically type the company name when i type the policy no. in excel,
this can be done easily. pls help.

rp
 
G

Guest

hi,
you will need code in the policy numbers text box.
Asumming the table they are in is tbl and the fileds are
Policy number = PolNum and company name = conam and on
your form you have text boxes txtPolnum and txtConam.

Private Sub txtPolNum_BeforeUpdate(Cancel As Integer)
If IsNull(Me.txtPolNum) Then
Cancel = True
Else
me.txtconam=(DLookup("[coman]", "tbl", "[PolNum] = '" &
Me.txtPolnum & "'"))
End If
End Sub

Note: the line that starts "me.txtconam =" wrapped. that
is supposed to be one line.
regards
 
Top