B
_Bigred
I am trying to setup a db so when you open
the Discipline Manager Form (based on tblDisciplineLog)
you enter the NumberID which is a Inmate Number (each inmate has a unique
number that never changes while they are incarcerated in the state) I wan't
to automatically fill the remaining fields LastName, FirstName, RoomID from
the data from tblMaster that corresponds to the NumberID
I tried to create a form based on the [tblDisciplineLog] and then set the
NumberID field on the form to do a OnExit code to update the remaining
fields I used the below code:
Sub NumberID_OnExit(Cancel As Integer)
Dim varLastName, varFirstName As Variant
varLastName = DLookup("LastName", "tblMaster", "NumberID =[NumberID] ")
varFirstName = DLookup("FirstName", "tblMaster", "NumberID =[NumberID] ")
If (Not IsNull(varLastName)) Then Me![LastName] = varLastName
If (Not IsNull(varFirstName)) Then Me![FirstName] = varFirstName
End Sub
(Just a quick thought do I need to set a relationship from the table menu
between the NumberID in both tblMaster and tblDisciplineLog to make the code
work?)
Any ideas of what I'm doing wrong or how to fix it would be appreciated.
_Bigred
the Discipline Manager Form (based on tblDisciplineLog)
you enter the NumberID which is a Inmate Number (each inmate has a unique
number that never changes while they are incarcerated in the state) I wan't
to automatically fill the remaining fields LastName, FirstName, RoomID from
the data from tblMaster that corresponds to the NumberID
I tried to create a form based on the [tblDisciplineLog] and then set the
NumberID field on the form to do a OnExit code to update the remaining
fields I used the below code:
Sub NumberID_OnExit(Cancel As Integer)
Dim varLastName, varFirstName As Variant
varLastName = DLookup("LastName", "tblMaster", "NumberID =[NumberID] ")
varFirstName = DLookup("FirstName", "tblMaster", "NumberID =[NumberID] ")
If (Not IsNull(varLastName)) Then Me![LastName] = varLastName
If (Not IsNull(varFirstName)) Then Me![FirstName] = varFirstName
End Sub
(Just a quick thought do I need to set a relationship from the table menu
between the NumberID in both tblMaster and tblDisciplineLog to make the code
work?)
Any ideas of what I'm doing wrong or how to fix it would be appreciated.
_Bigred