Results 1 to 2 of 2
  1. #1
    Join Date
    May 2005
    Posts
    54

    Unanswered: Help for DLookup Function

    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.

  2. #2
    Join Date
    Dec 2004
    Location
    Madison, WI
    Posts
    3,926

    Dlookup

    Not sure about the EmpNo.Undo and Cancel = True but you might want to look at the syntax on:

    If IsNull(DLookup("[EmpNo]", "Combine", "[EmpNo]=forms![TADA]!EmpNo")) Then

    to (if EmpNo is a string field)
    If IsNull(DLookup("[EmpNo]", "Combine", "[EmpNo]= '" & forms![TADA]!EmpNo & "'")) Then

    or (if EmpNo is a number field)
    If IsNull(DLookup("[EmpNo]", "Combine", "[EmpNo]= " & forms![TADA]!EmpNo & ")) Then
    Expert Database Programming
    MSAccess since 1.0, SQL Server since 6.5, Visual Basic (5.0, 6.0)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •