Dlookup Function need help

  • Thread starter Thread starter Wasim Yasin via AccessMonster.com
  • Start date Start date
W

Wasim Yasin via AccessMonster.com

Dear All

I have fileds like Emp no, Name, Grade etc. in my Master table. I also have a
transaction table 'TADA' having the same fileds. The form is based on
transaction table 'TADA'. Now I used the dlookup function on 'Emp No' field
of form as following.

If IsNull(DLookup("[EmpNo]", "Combine", "[EmpNo]=forms![TADA]!EmpNo")) Then
MsgBox "Please Enter Correct Emp No."
EmpNo.Undo
Cancel = True
End If
I'm getting error on last two Italic lines.
Second I want that when a n emp no matched with master table then the name,
grade and designation fileds of form populated with master table fileds of
name, grade and designation and control transfer to naxt field. Is it
possible or not? Please help.

Thanx.
 
To what does EmpNo in the EmpNo.Undo statement refer? Assuming it's a bound
textbox, the problem might be that the name of the textbox is probably the
same as the name of the recordsource field to which it's bound (a stupid
default Microsoft implemented!). Try renaming the textbox to, say, txtEmpNo,
then using Me.txtEmpNo.Undo instead of what you have.

What event do you have that code in? Not all events have a Cancel parameter
(which would explain why it's complaining about setting Cancel = True). The
BeforeUpdate event does.
 
Any body can help.

Wasim said:
Dear All

I have fileds like Emp no, Name, Grade etc. in my Master table. I also have a
transaction table 'TADA' having the same fileds. The form is based on
transaction table 'TADA'. Now I used the dlookup function on 'Emp No' field
of form as following.

If IsNull(DLookup("[EmpNo]", "Combine", "[EmpNo]=forms![TADA]!EmpNo")) Then
MsgBox "Please Enter Correct Emp No."
EmpNo.Undo
Cancel = True
End If
I'm getting error on last two Italic lines.
Second I want that when a n emp no matched with master table then the name,
grade and designation fileds of form populated with master table fileds of
name, grade and designation and control transfer to naxt field. Is it
possible or not? Please help.

Thanx.
 
Back
Top