Results 1 to 2 of 2
  1. #1
    IKZOUHETNIETWETEN is offline Novice
    Windows Vista Access 2007
    Join Date
    Oct 2015
    Posts
    6

    Dlookup

    By adding an unit number A1 and an OUT date in the form, i want to get a message that an error/popup message that its already OUT (and so cant be added in the table). (Because unitnumber A1 is already in the table as A1 with an OUT date)


    Table name: Units
    Form name: Units
    field1 = Unit_name
    field2= In_date
    field3= Out_date
    field4 = Project_name

    This is what I have so far:

    Code:
    Private Sub Unit_name_BeforeUpdate(Cancel As Integer)
    DLookUp("Units", "[Unit_name]= " & [Unit_name] & " And [Date_out]= '" & [Date_out] & "'")
      MsgBox "Name Is Already In Database!"
    End If
    End Sub

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    This should help:

    http://access.mvps.org/access/general/gen0018.htm

    also, you can't use the DLookup() like that. I'd use DCount() and test for greater than zero.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

Please reply to this thread with any new information or opinions.

Similar Threads

  1. If and Dlookup
    By Zinger in forum Programming
    Replies: 6
    Last Post: 10-17-2015, 04:47 PM
  2. dlookup
    By ali zaib in forum Access
    Replies: 3
    Last Post: 01-13-2012, 11:57 AM
  3. Dlookup help
    By justhininabouti in forum Programming
    Replies: 2
    Last Post: 11-26-2011, 10:53 PM
  4. Dlookup
    By cbrsix in forum Forms
    Replies: 2
    Last Post: 11-01-2011, 02:59 PM
  5. Dlookup
    By cbrsix in forum Forms
    Replies: 6
    Last Post: 11-01-2011, 10:38 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums