Results 1 to 3 of 3
  1. #1
    Join Date
    Oct 2009
    Posts
    204

    Unanswered: Dlookup error...

    Hello,

    I am having a problem getting a Vlookup to work. This first bit of code works fine.....what it does is checks the enterTO field in form frm_RFPicking1 against the TO field in table frm_TO, and if they match, it runs a query and opens another form....if they do not match, it flashes for a couple seconds a label which shows an error.

    This is the same code I was using, but with fields and pasted from a different table:

    Code:
    Private Sub Command17_Click()
    Dim i As Long
    i = 0
    If [Forms]![frm_RFPicking1]![enterTO] = DLookup("TO", "frm_TO") Then
    DoCmd.SetWarnings False
    DoCmd.OpenQuery "qry_appendTO"
    DoCmd.SetWarnings True
    DoCmd.Close acForm, Me.Name
    DoCmd.OpenForm "frm_RFPicking2"
    Else
    Me.invalid.Visible = True
    Me.to.Visible = False
    Me.Repaint
    Do
    i = i + 1
    Me.Repaint
    Loop Until i = 60000
    
    Me.to.Visible = True
    Me.invalid.Visible = False
    Me.enterTO = ""
    End If
    End Sub
    I wanted to add more criteria to this with another warning label, but this part of the dlookup that I added does not work. The field "Confirm" is a yes/no check box.

    Does anyone know how I would fix this?

    Thanks,
    Chris


    Code:
    Private Sub enterTO_AfterUpdate()
    Dim i As Long
    i = 0
    Dim c As Boolean
    c = False
    Dim d As Boolean
    d = True
    
    If [Forms]![frm_RFPicking2]![enterTO] = DLookup("Item", "frm_TransferOrder", "Confirm" = c) Then
    DoCmd.SetWarnings False
    DoCmd.OpenQuery "qry_appendTO2"
    DoCmd.SetWarnings True
    DoCmd.Close acForm, Me.Name
    DoCmd.OpenForm "frm_RFPicking3"
    Else
    If [Forms]![frm_RFPicking2]![enterTO] = DLookup("Item", "frm_TransferOrder", "Confirm" = d) Then
        Me.confirmed.Visible = True
        Me.to.Visible = False
        Me.Repaint
        Do
        i = i + 1
        Me.Repaint
        Loop Until i = 60000
        Me.to.Visible = True
        Me.confirmed.Visible = False
        Me.enterTO = ""
        End If
    Me.invalid.Visible = True
    Me.to.Visible = False
    Me.Repaint
    Do
    i = i + 1
    Me.Repaint
    Loop Until i = 60000
    Me.to.Visible = True
    Me.invalid.Visible = False
    Me.enterTO = ""
    End If
    End Sub

  2. #2
    Join Date
    May 2005
    Location
    Nevada, USA
    Posts
    2,888
    Provided Answers: 6
    Try

    DLookup("Item", "frm_TransferOrder", "Confirm = " & c)
    Paul

  3. #3
    Join Date
    Oct 2009
    Posts
    204
    Quote Originally Posted by pbaldy View Post
    Try

    DLookup("Item", "frm_TransferOrder", "Confirm = " & c)
    PERFECT!

    Thank you sir!

Posting Permissions

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