Results 1 to 5 of 5
  1. #1
    adam23262 is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Feb 2013
    Posts
    2

    Check if record is exits in table

    Hi,

    I am trying to check if a record exits in a table.


    Dim cert As String
    Dim existingRec As Variant

    existingRec = DLookup("[Certificate]", "[Fire]", "'cert' = 'cert'")

    If existingRec = Null Then

    Else
    MsgBox "The Certificate " & existingRec & " is in the database"

    End If



    Note - Certificate is a column in the table "Fire"

    Problem is that existingRec only finds the first value in the Certificate column,
    How do I get to check the entire Certificate column?


    Thanks

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Cannot use = Null

    Review http://allenbrowne.com/casu-12.html

    If IsNull(existingRec) Then
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    alcapps is offline Competent Performer
    Windows 8 Access 2010 32bit
    Join Date
    Jan 2012
    Posts
    292
    existingRec = DLookup("[Certificate]", "[Fire]", "'cert' = 'cert'")

    "'cert' = 'cert'" this is the where clause in dlookup

    so what are trying to do with this statement?

    Usually this is where you would single out the record to see if it has a certificate.

  4. #4
    adam23262 is offline Novice
    Windows 7 64bit Access 2010 32bit
    Join Date
    Feb 2013
    Posts
    2
    Hi alcapps,

    I am trying to compare cert against the column Certificate, I need to find out if cert is already in the table.

  5. #5
    alcapps is offline Competent Performer
    Windows 8 Access 2010 32bit
    Join Date
    Jan 2012
    Posts
    292
    if certificate is a string use this..
    DLookup("[Certificate]", "[Fire]", "[Certificate] = '" & me.cert & "'")
    if certificate is a number use this
    DLookup("[Certificate]", "[Fire]", "[Certificate] = " & me.cert )


    change me.cert to the field name.. me.fieldname

    hope this helps..

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

Similar Threads

  1. Check if record exists, Check Number
    By burrina in forum Forms
    Replies: 9
    Last Post: 01-06-2013, 03:49 PM
  2. Replies: 3
    Last Post: 10-19-2012, 04:30 PM
  3. Replies: 1
    Last Post: 03-06-2012, 06:45 PM
  4. Replies: 9
    Last Post: 11-22-2011, 05:23 PM
  5. Check to see if record id exists in joined table
    By csoseman in forum Programming
    Replies: 1
    Last Post: 08-18-2011, 01:06 PM

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