auto populate field based on other table

rashidzaib

Registered User.
Local time
Today, 10:38
Joined
Aug 12, 2007
Messages
32
hy
i hope all are fine
i am in huge trouble.
actually i am oracle programer. but my user has asked me to develop a small
program in access. now approximately i have developed the program.
but one problem remaining.
my problem is this i have one table in which i am taking value based on other table this is ok. but i want some value to be inserted automaticaly if i select a code relative name is inserted in the name field.
example

i have department table in which
deptcode and deptname field is there.

this is matter of situation i know that if i use in this way database is not normalize but this is required.
in item code table i have deptcode and i need daptname aslo.
i can select deptcode from department table. but the requirment is this if i select deptcode the deptname field is auto populated from department table in item code form.
i hope u will understand my problem.
any help should really be appriciated.
thank u and best regards
ur truly rashid zaib
 
i have written this code in item code dept name field


Private Sub DEPTNAME_Enter()
Me.DEPTNAME = [SELECT description from department where department.detpcode=me.DEPTCODE]
End Sub


but getting the error 2465

one record is coming but giving error
pls help me
bye
 
R,

Use a DLookUp function call.
Since it can return Null (If invalid deptcode), use the Nz function around it.

Me.DEPTNAME = Nz(DLookUp("[description]", "department", "[detpcode] = " & Me.DEPTCODE), "")

detpcode <-- ???

Wayne
 
this is working

hy Mr. Wayne
thank u very very much for helping me. the code u have given me is working properly.
thank u again
take care
bye
 

Users who are viewing this thread

Back
Top Bottom