Results 1 to 5 of 5
  1. #1
    jgelpi is offline Novice
    Windows XP Access 2003
    Join Date
    May 2009
    Posts
    19

    Question Delete erroneous record(s)


    I am some serious need of some help. I have a form where users sign in each day. I have a stop to keep users from signing in more than once. However, if the user tries to sign in more than once, after the error message pops up, the user hits "OK", and the record is still created in the database. I need to either stop that blank record from being created, or delete it once it is created (without the user receiving an error message of any kind). I have included the code in the "Before Update" procedure. Any help on this will be much appreciated.

    Code:
     
    Private Sub Combo42_BeforeUpdate(Cancel As Integer)
    Dim dbTemp As Database
    Dim rsTemp As DAO.Recordset
    Set dbTemp = CurrentDb()
    Set rsTemp = dbTemp.OpenRecordset("SELECT * FROM tblTimeTrack" _
    & " WHERE " _
    & "Name = '" & Me.Combo42.Value & "'" _
    & " AND Date = #" & Format(Me.Date.Value) & "#" _
    ) 
     
    If Not rsTemp.EOF Then
    Combo42.Undo
    Cancel = MsgBox("You have already signed in today, Please use Name Lookup.", _
    vbCritical, "Cannot save")
    
    End If
    rsTemp.Close
    Set rsTemp = Nothing
    End Sub

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 10 Access 2013 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    There is nothing in this code to create a new record that I can see but Me.UnDo will reset all of the controls on the form if that helps.

  3. #3
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 10 Access 2013 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    BTW, I deleted your duplicate thread that was marked as solved as it did not seem to serve any useful purpose.

  4. #4
    jgelpi is offline Novice
    Windows XP Access 2003
    Join Date
    May 2009
    Posts
    19

    Solved!

    The Me.Undo did solve the problem. So simple, yet I could not put my finger on it! Thanks a lot for the help!

  5. #5
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 10 Access 2013 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Great! Glad we could help.

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

Similar Threads

  1. HELP with Delete Query
    By brown in forum Queries
    Replies: 1
    Last Post: 04-22-2009, 10:11 PM
  2. Two Delete Record Problems
    By skyrise in forum Programming
    Replies: 1
    Last Post: 04-22-2009, 09:37 PM
  3. Replies: 0
    Last Post: 04-13-2009, 04:02 AM
  4. Delete a record
    By f.crocco in forum Programming
    Replies: 1
    Last Post: 10-08-2007, 07:28 AM
  5. Could not delete from specified tables.
    By bullwinkle55423 in forum Queries
    Replies: 0
    Last Post: 08-31-2006, 08:14 AM

Tags for this Thread

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