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.Clo ne.
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.....
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.Clo
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
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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.
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.
ASKER
'Set rs = Forms!MyForm.RecordsetClon e' done the trick. Strange one but it works, many thanks
Jim.