Link to home
Start Free TrialLog in
Avatar of padrepio2
padrepio2

asked on

MS Accss DAO Issue

The following code crashes MS Access every time.  The database used to reside on a laptop with Access 2007.  Issues have occurred since I’ve installed the database on a PC running Access 2013.

The code is triggered by double clicking a list box, it’s the same code as other forms that bizarrely continues to work without issue.

I’ve commented out all the code and reinstated each line until Access crashes – it occurs at the line    Set rs = Forms!MyForm.Recordset.Clone.  

Previously the code had the following declaration:  Dim rs as DAO.Recordset so I changed it to fall in line with the other forms code that clearly does work  ie Dim rs As Object.

Suspect it may be a reference issue but why does it work on other forms?  I've imported all objects into a new database but it continues to crash.....



Dim rs As Object

    DoCmd.OpenForm "MyForm"

    Set rs = Forms!MyForm.Recordset.Clone

    rs.FindFirst "[signinID] = " & Str(Nz(Me![List122], 2))

    If Not rs.EOF Then Forms!MyForm.Bookmark = rs.Bookmark

    DoCmd.Close acForm, Me.Name

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Dale Fye
Dale Fye
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Can you give a little more detail in regards to the crash?   Does it fault?  If so is the address and module always the same?   If so, then you've most likely tripped over an Access bug or have a corrupt form, or VBA project.

Jim.
Is "signinID" a Numeric or Text value? I ask because you're using Str, which returns a STRING representation of a Number. If signinID is a number, then you don't need to use STR to convert it to a string. If it's a string, then you need to enclose it in quotes.

And while I know this was working in previous versions, we've seen quite a few instances where that same code will fail in newer versions of Access/VBA. Not sure why, but it does happen more than you'd think.

Only other piece of advice I have is make sure your Office and Windows installations are fully up to date.
Avatar of padrepio2
padrepio2

ASKER

'Set rs = Forms!MyForm.RecordsetClone' done the trick.  Strange one but it works, many thanks