Results 1 to 4 of 4
  1. #1
    Join Date
    Aug 2004
    Posts
    54

    Talking Unanswered: Am I missing something on my DLOOKUP?

    I get a "You cancelled the previous operation" error whenever I try to run the code....



    If cbBallbarInstalled.Value = "SST" Then
    ' Declare the variables.
    Dim MfgID As Long
    Dim TypeName As String
    Dim Result As Currency

    ' Assign values to the variables to be used in the criteria.
    MfgID = Me.txtManufacturerID
    TypeName = "Ballbar"
    Result = DLookup("[ServiceTypeCost]", "ServiceType", "[ManufacturerID] = '" & MfgID & "' And [ServiceTypeName] = " & TypeName)

    Result = txtBallbarSalesCost.Value


    Else: txtBallbarSalesCost.Value = 0
    End If

  2. #2
    Join Date
    Jan 2005
    Posts
    6
    ORIGINAL:
    Result = DLookup("[ServiceTypeCost]", "ServiceType", "[ManufacturerID] = '" & MfgID & "' And [ServiceTypeName] = " & TypeName)

    The ManufacturerID is an integer and the ServiceTypeName a text field, so:

    NEW:
    Result = DLookup("[ServiceTypeCost]", "ServiceType", "[ManufacturerID] = " & MfgID & " And [ServiceTypeName] = '" & TypeName & "'")

    you don't need the single quotes around the MfgID, but you do around the TypeName.

  3. #3
    Join Date
    Nov 2004
    Location
    Bangor, ME USA
    Posts
    44
    calfuzz,

    do you also realize that you invalidate the lookup with your next line?
    Code:
    Result = DLookup("[ServiceTypeCost]", "ServiceType", "[ManufacturerID] = '" & MfgID & "' And [ServiceTypeName] = " & TypeName)
    
    Result = txtBallbarSalesCost.Value
    Result = dlookup is going to put in some value but then your next line would erase that value because you are setting result to the value of txtballbarsalescost

    what I think you wantes was txtballbarsalescost = result.

    so tak what hawkeyeboy did and then reverse the next line to read as above.

    good luck, HTH
    Kevin

  4. #4
    Join Date
    Aug 2004
    Posts
    54
    Thanks

    Yep, I realized the null error as soon as I ran it. Took me a second, I should know better.

Posting Permissions

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