Results 1 to 4 of 4
  1. #1
    DMT Dave is online now VIP
    Windows 10 Access 2016
    Join Date
    May 2018
    Posts
    1,191

    Code Freezes database

    Hi Guy's, the following code freezes the database having t0 ctrl-alt-delete to end task and reopen ?



    All field names are correct after checking that

    This code is to search any part of a telephone number

    Code:
    Dim rs As DAO.Recordset, rs2 As DAO.Recordset
    Dim mBody as String, mTel as String
    mTel = Me.txtTel
    Set rs = CurrentDb.OpenRecordset("Select tblEmails.Client, tblEmails.Postcode, tblEmails.Item, tblEmails.Tel From tblEmails WHERE Tel Like ""*" & mTel & "*""")
    Do Until rs.EOF
    mBody = rs.Fields("Client") & "-" & rs.Fields("PostCode") & "-" & rs.Fields("Item") & "-" & rs.Fields("Tel") & vbNewLine
    Loop
    MsgBox (mBody)
    Set rs = Nothing
    

  2. #2
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,976
    Try adding rs.MoveFirst after the Set rs line
    Do you have any null values in the recordset?
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  3. #3
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,424
    you also need a movenext before you loop

  4. #4
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,976
    Oops. Missed that!
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

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

Similar Threads

  1. Importing large file freezes up DB
    By Bcanfield83 in forum Import/Export Data
    Replies: 2
    Last Post: 04-01-2019, 11:30 AM
  2. Access 2003 Freezes
    By bell in forum Access
    Replies: 3
    Last Post: 12-16-2015, 08:24 AM
  3. Access freezes up and crashes
    By CompTechRx in forum Access
    Replies: 5
    Last Post: 11-01-2011, 02:53 PM
  4. Forms Freezes After Record Is Updated
    By toonz in forum Forms
    Replies: 1
    Last Post: 10-04-2011, 01:09 PM
  5. Access Freezes at startup
    By pokerim in forum Access
    Replies: 1
    Last Post: 07-20-2010, 06:28 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