Results 1 to 5 of 5
  1. #1
    wtolentino is offline Novice
    Windows 7 64bit Access 2016
    Join Date
    Mar 2009
    Posts
    13

    Login Form

    i created an unbound form. in that form i want to search/find a record in a table to check if the record exist. how do i code it. thanks.

  2. #2
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 7 32bit Access 2013
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,614
    Take a look at the DCount() function and the criteria that can be used. If it returns 0 then no record exists.
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  3. #3
    wtolentino is offline Novice
    Windows 7 64bit Access 2016
    Join Date
    Mar 2009
    Posts
    13
    many thanks that works.

  4. #4
    wtolentino is offline Novice
    Windows 7 64bit Access 2016
    Join Date
    Mar 2009
    Posts
    13
    i am using the same dcount() function in other forms to check for existing records in a table. on that form i code it on the on delete event to check for the record on another table. how do i code it to stop/prevent if the dcount() is > 0. i know the if statement however i am not familiar with ms access function to stop/prevent a delete. thanks.

    for example.
    Code:
      Dim vCount
      vCount = DCount("room_id", "tblClassLine", "room_id = " & [Forms]![frmRoom]![room_id])
      
      if vCount > 0 then
        stop
      end if

  5. #5
    aytee111 is offline Competent At Times
    Windows 10 Access 2013 64bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    Cancel=True
    This applies to all events that have it as a parameter/provide it as an option.

    You could also set the referential integrity in the Relationships window to prevent deletions.

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

Similar Threads

  1. Replies: 4
    Last Post: 07-17-2015, 10:04 AM
  2. Replies: 2
    Last Post: 04-17-2015, 10:59 AM
  3. Replies: 3
    Last Post: 03-17-2014, 10:23 AM
  4. Replies: 1
    Last Post: 12-11-2011, 11:48 AM
  5. Login form with nt login
    By hitesh_asrani_j in forum Forms
    Replies: 6
    Last Post: 09-22-2011, 11:43 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