PC Review
Forums
Newsgroups
Microsoft Access
Microsoft Access VBA Modules
can't open recordset
Forums
Newsgroups
Microsoft Access
Microsoft Access VBA Modules
can't open recordset
![]() |
can't open recordset |
|
|
Thread Tools | Rate Thread |
|
|
#1 |
|
Guest
Posts: n/a
|
I've used this code a thousand times, but now I get a 'type mismatch' error
at the command 'set rs = CurrentDb.OpenRecordset(strSQL, dbOpenDynaset)'. This is in a new access database. (yeah I know, currentdb is temporary but it works) Private Sub Command0_Click() Dim rs As Recordset Dim strSQL As String strSQL = "SELECT ACTIAImport.* FROM ACTIAImport;" Set rs = CurrentDb.OpenRecordset(strSQL, dbOpenDynaset) rs.MoveFirst 'etcetc End Sub As in every other case, I have tools>references: Visual Basic for Applications Microsoft Access 10.0 object library Microsoft DAO 3.6 object library OLE Automation Micorsoft ActiveX Data Objects 2.8 Library Compile doesn't have any problems with it, and when I copy the code into a working database it works fine. What am I missing? Thanks |
|
|
|
#2 |
|
Guest
Posts: n/a
|
Even though you have DAO higher in the list than ADO, see whether changing
Dim rs As Recordset to Dim rs As DAO.Recordset makes a difference. -- Doug Steele, Microsoft Access MVP http://I.Am/DougSteele (no e-mails, please!) "Fredrated" <Fredrated@discussions.microsoft.com> wrote in message news:8F3E359C-C407-4D1D-8EC0-B45BF910C125@microsoft.com... > I've used this code a thousand times, but now I get a 'type mismatch' > error > at the command 'set rs = CurrentDb.OpenRecordset(strSQL, dbOpenDynaset)'. > This is in a new access database. > (yeah I know, currentdb is temporary but it works) > > > Private Sub Command0_Click() > Dim rs As Recordset > Dim strSQL As String > > strSQL = "SELECT ACTIAImport.* FROM ACTIAImport;" > > Set rs = CurrentDb.OpenRecordset(strSQL, dbOpenDynaset) > rs.MoveFirst > 'etcetc > > End Sub > > As in every other case, I have tools>references: > Visual Basic for Applications > Microsoft Access 10.0 object library > Microsoft DAO 3.6 object library > OLE Automation > Micorsoft ActiveX Data Objects 2.8 Library > > Compile doesn't have any problems with it, and when I copy the code into a > working database it works fine. > > What am I missing? > > Thanks |
|
|
|
#3 |
|
Guest
Posts: n/a
|
Never mind, I just opened a new database, copied what I want into it and it
now works fine. I ran compact/repair on the original failing database but that didn't help. Who knows why it fails, probably something internal got messed up. "Fredrated" wrote: > I've used this code a thousand times, but now I get a 'type mismatch' error > at the command 'set rs = CurrentDb.OpenRecordset(strSQL, dbOpenDynaset)'. > This is in a new access database. > (yeah I know, currentdb is temporary but it works) > > > Private Sub Command0_Click() > Dim rs As Recordset > Dim strSQL As String > > strSQL = "SELECT ACTIAImport.* FROM ACTIAImport;" > > Set rs = CurrentDb.OpenRecordset(strSQL, dbOpenDynaset) > rs.MoveFirst > 'etcetc > > End Sub > > As in every other case, I have tools>references: > Visual Basic for Applications > Microsoft Access 10.0 object library > Microsoft DAO 3.6 object library > OLE Automation > Micorsoft ActiveX Data Objects 2.8 Library > > Compile doesn't have any problems with it, and when I copy the code into a > working database it works fine. > > What am I missing? > > Thanks |
|
![]() |
|
| Thread Tools | |
| Rate This Thread | |
|
|

Main Page 

