PC Review


Reply
Thread Tools Rate Thread

95 Code Won't Work In 2000

 
 
Keith Willcocks
Guest
Posts: n/a
 
      21st Jul 2007
I used to use Access 95 VBA but now have to do something in Access 2000.

The following in Declarations:
Dim dbs As Database
Dim rst As Recordset

Followed in a procedure by:
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("tblMain")

Would open the table for use. However, in Access 2000, this simply results
in error messages. As far as I can see the Database option in "Dim dbs As
Database" no longer works and is giving me Type Mismatch messages. How do
I do this operation in Access 2000 please? Oh, can you keep it simple
please, I haven't touched Access for 6 or 7 years.

--
Keith Willcocks
(If you can't laugh at life, it ain't worth living!)


 
Reply With Quote
 
 
 
 
Allen Browne
Guest
Posts: n/a
 
      21st Jul 2007
You need to add the DAO library reference:
http://allenbrowne.com/ser-38.html

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Keith Willcocks" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>I used to use Access 95 VBA but now have to do something in Access 2000.
>
> The following in Declarations:
> Dim dbs As Database
> Dim rst As Recordset
>
> Followed in a procedure by:
> Set dbs = CurrentDb
> Set rst = dbs.OpenRecordset("tblMain")
>
> Would open the table for use. However, in Access 2000, this simply
> results in error messages. As far as I can see the Database option in
> "Dim dbs As Database" no longer works and is giving me Type Mismatch
> messages. How do I do this operation in Access 2000 please? Oh, can
> you keep it simple please, I haven't touched Access for 6 or 7 years.


 
Reply With Quote
 
Keith Willcocks
Guest
Posts: n/a
 
      21st Jul 2007
Many thanks for that Allen. I have now installed the DAO Library and
"Database" is now recognised in the Declarations. Curiously though I am
still getting a Type Mismatch message. This is my actual code if you can
see anything daft that I cannot see for the trees:

Declaration:
Dim dbs As Database
Dim rst As Recordset
- - - - - - - - - - - - - - - - - - - - - - - - - - - -
Private Sub cmdIssuesSubmit_Click()
On Error GoTo Err_cmdIssuesSubmit_Click
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("tblMain")
rst.MoveFirst

Exit_Err_cmdIssuesSubmit_Click:
Exit Sub

Err_cmdIssuesSubmit_Click:
MsgBox Err.Description
Resume Exit_Err_cmdIssuesSubmit_Click

End Sub

Stepping through in debug with F8, the error message Type Mismatch is thrown
up as soon as the line Set rst = dbs.OpenRecordset("tblMain") is executed.
The table has four short date/time fields and all the others are Text.
There is one record in the table with data in the Primary Key (number 1) and
Text in the first two Text fields. I have rigorously checked all the
spellings in the code.

I am totally puzzled by this and can see no reason for it.

Keith Willcocks

"Allen Browne" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> You need to add the DAO library reference:
> http://allenbrowne.com/ser-38.html
>
> --
> Allen Browne - Microsoft MVP. Perth, Western Australia
> Tips for Access users - http://allenbrowne.com/tips.html
> Reply to group, rather than allenbrowne at mvps dot org.
>
> "Keith Willcocks" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>>I used to use Access 95 VBA but now have to do something in Access 2000.
>>
>> The following in Declarations:
>> Dim dbs As Database
>> Dim rst As Recordset
>>
>> Followed in a procedure by:
>> Set dbs = CurrentDb
>> Set rst = dbs.OpenRecordset("tblMain")
>>
>> Would open the table for use. However, in Access 2000, this simply
>> results in error messages. As far as I can see the Database option in
>> "Dim dbs As Database" no longer works and is giving me Type Mismatch
>> messages. How do I do this operation in Access 2000 please? Oh, can
>> you keep it simple please, I haven't touched Access for 6 or 7 years.

>



 
Reply With Quote
 
Allen Browne
Guest
Posts: n/a
 
      21st Jul 2007
Change the line:
Dim rst As DAO.Recordset
to:
Dim rst As Recordset

The ADO library has a Recordset object as well. If you are getting a type
mismatch, Access might be giving you the wrong one, so the above
disambiguates.

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Keith Willcocks" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Many thanks for that Allen. I have now installed the DAO Library and
> "Database" is now recognised in the Declarations. Curiously though I am
> still getting a Type Mismatch message. This is my actual code if you can
> see anything daft that I cannot see for the trees:
>
> Declaration:
> Dim dbs As Database
> Dim rst As Recordset
> - - - - - - - - - - - - - - - - - - - - - - - - - - - -
> Private Sub cmdIssuesSubmit_Click()
> On Error GoTo Err_cmdIssuesSubmit_Click
> Set dbs = CurrentDb
> Set rst = dbs.OpenRecordset("tblMain")
> rst.MoveFirst
>
> Exit_Err_cmdIssuesSubmit_Click:
> Exit Sub
>
> Err_cmdIssuesSubmit_Click:
> MsgBox Err.Description
> Resume Exit_Err_cmdIssuesSubmit_Click
>
> End Sub
>
> Stepping through in debug with F8, the error message Type Mismatch is
> thrown up as soon as the line Set rst = dbs.OpenRecordset("tblMain") is
> executed. The table has four short date/time fields and all the others are
> Text. There is one record in the table with data in the Primary Key
> (number 1) and Text in the first two Text fields. I have rigorously
> checked all the spellings in the code.
>
> I am totally puzzled by this and can see no reason for it.
>
> Keith Willcocks
>
> "Allen Browne" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> You need to add the DAO library reference:
>> http://allenbrowne.com/ser-38.html
>>
>> "Keith Willcocks" <(E-Mail Removed)> wrote in message
>> news:(E-Mail Removed)...
>>>I used to use Access 95 VBA but now have to do something in Access 2000.
>>>
>>> The following in Declarations:
>>> Dim dbs As Database
>>> Dim rst As Recordset
>>>
>>> Followed in a procedure by:
>>> Set dbs = CurrentDb
>>> Set rst = dbs.OpenRecordset("tblMain")
>>>
>>> Would open the table for use. However, in Access 2000, this simply
>>> results in error messages. As far as I can see the Database option in
>>> "Dim dbs As Database" no longer works and is giving me Type Mismatch
>>> messages. How do I do this operation in Access 2000 please? Oh,
>>> can you keep it simple please, I haven't touched Access for 6 or 7
>>> years.


 
Reply With Quote
 
Arvin Meyer [MVP]
Guest
Posts: n/a
 
      21st Jul 2007
Allen mean the opposite:

Change the line:

Dim rst As Recordset

to:

Dim rst As DAO.Recordset
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com

"Allen Browne" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> Change the line:
> Dim rst As DAO.Recordset
> to:
> Dim rst As Recordset
>
> The ADO library has a Recordset object as well. If you are getting a type
> mismatch, Access might be giving you the wrong one, so the above
> disambiguates.
>
> --
> Allen Browne - Microsoft MVP. Perth, Western Australia
> Tips for Access users - http://allenbrowne.com/tips.html
> Reply to group, rather than allenbrowne at mvps dot org.
>
> "Keith Willcocks" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> Many thanks for that Allen. I have now installed the DAO Library and
>> "Database" is now recognised in the Declarations. Curiously though I
>> am still getting a Type Mismatch message. This is my actual code if you
>> can see anything daft that I cannot see for the trees:
>>
>> Declaration:
>> Dim dbs As Database
>> Dim rst As Recordset
>> - - - - - - - - - - - - - - - - - - - - - - - - - - - -
>> Private Sub cmdIssuesSubmit_Click()
>> On Error GoTo Err_cmdIssuesSubmit_Click
>> Set dbs = CurrentDb
>> Set rst = dbs.OpenRecordset("tblMain")
>> rst.MoveFirst
>>
>> Exit_Err_cmdIssuesSubmit_Click:
>> Exit Sub
>>
>> Err_cmdIssuesSubmit_Click:
>> MsgBox Err.Description
>> Resume Exit_Err_cmdIssuesSubmit_Click
>>
>> End Sub
>>
>> Stepping through in debug with F8, the error message Type Mismatch is
>> thrown up as soon as the line Set rst = dbs.OpenRecordset("tblMain") is
>> executed. The table has four short date/time fields and all the others
>> are Text. There is one record in the table with data in the Primary Key
>> (number 1) and Text in the first two Text fields. I have rigorously
>> checked all the spellings in the code.
>>
>> I am totally puzzled by this and can see no reason for it.
>>
>> Keith Willcocks
>>
>> "Allen Browne" <(E-Mail Removed)> wrote in message
>> news:(E-Mail Removed)...
>>> You need to add the DAO library reference:
>>> http://allenbrowne.com/ser-38.html
>>>
>>> "Keith Willcocks" <(E-Mail Removed)> wrote in message
>>> news:(E-Mail Removed)...
>>>>I used to use Access 95 VBA but now have to do something in Access 2000.
>>>>
>>>> The following in Declarations:
>>>> Dim dbs As Database
>>>> Dim rst As Recordset
>>>>
>>>> Followed in a procedure by:
>>>> Set dbs = CurrentDb
>>>> Set rst = dbs.OpenRecordset("tblMain")
>>>>
>>>> Would open the table for use. However, in Access 2000, this simply
>>>> results in error messages. As far as I can see the Database option in
>>>> "Dim dbs As Database" no longer works and is giving me Type Mismatch
>>>> messages. How do I do this operation in Access 2000 please? Oh,
>>>> can you keep it simple please, I haven't touched Access for 6 or 7
>>>> years.

>



 
Reply With Quote
 
Allen Browne
Guest
Posts: n/a
 
      21st Jul 2007
Thanks, Arvin.

(It's 1:15am here. They should not let me near the keyboard!)

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Arvin Meyer [MVP]" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Allen mean the opposite:
>
> Change the line:
>
> Dim rst As Recordset
>
> to:
>
> Dim rst As DAO.Recordset
> --
> Arvin Meyer, MCP, MVP
> http://www.datastrat.com
> http://www.mvps.org/access
> http://www.accessmvp.com
>
> "Allen Browne" <(E-Mail Removed)> wrote in message
> news:%(E-Mail Removed)...
>> Change the line:
>> Dim rst As DAO.Recordset
>> to:
>> Dim rst As Recordset
>>
>> The ADO library has a Recordset object as well. If you are getting a type
>> mismatch, Access might be giving you the wrong one, so the above
>> disambiguates.
>>
>> "Keith Willcocks" <(E-Mail Removed)> wrote in message
>> news:(E-Mail Removed)...
>>> Many thanks for that Allen. I have now installed the DAO Library and
>>> "Database" is now recognised in the Declarations. Curiously though I
>>> am still getting a Type Mismatch message. This is my actual code if
>>> you can see anything daft that I cannot see for the trees:
>>>
>>> Declaration:
>>> Dim dbs As Database
>>> Dim rst As Recordset
>>> - - - - - - - - - - - - - - - - - - - - - - - - - - - -
>>> Private Sub cmdIssuesSubmit_Click()
>>> On Error GoTo Err_cmdIssuesSubmit_Click
>>> Set dbs = CurrentDb
>>> Set rst = dbs.OpenRecordset("tblMain")
>>> rst.MoveFirst
>>>
>>> Exit_Err_cmdIssuesSubmit_Click:
>>> Exit Sub
>>>
>>> Err_cmdIssuesSubmit_Click:
>>> MsgBox Err.Description
>>> Resume Exit_Err_cmdIssuesSubmit_Click
>>>
>>> End Sub
>>>
>>> Stepping through in debug with F8, the error message Type Mismatch is
>>> thrown up as soon as the line Set rst = dbs.OpenRecordset("tblMain") is
>>> executed. The table has four short date/time fields and all the others
>>> are Text. There is one record in the table with data in the Primary Key
>>> (number 1) and Text in the first two Text fields. I have rigorously
>>> checked all the spellings in the code.
>>>
>>> I am totally puzzled by this and can see no reason for it.
>>>
>>> Keith Willcocks
>>>
>>> "Allen Browne" <(E-Mail Removed)> wrote in message
>>> news:(E-Mail Removed)...
>>>> You need to add the DAO library reference:
>>>> http://allenbrowne.com/ser-38.html
>>>>
>>>> "Keith Willcocks" <(E-Mail Removed)> wrote in message
>>>> news:(E-Mail Removed)...
>>>>>I used to use Access 95 VBA but now have to do something in Access
>>>>>2000.
>>>>>
>>>>> The following in Declarations:
>>>>> Dim dbs As Database
>>>>> Dim rst As Recordset
>>>>>
>>>>> Followed in a procedure by:
>>>>> Set dbs = CurrentDb
>>>>> Set rst = dbs.OpenRecordset("tblMain")
>>>>>
>>>>> Would open the table for use. However, in Access 2000, this simply
>>>>> results in error messages. As far as I can see the Database option
>>>>> in "Dim dbs As Database" no longer works and is giving me Type
>>>>> Mismatch messages. How do I do this operation in Access 2000
>>>>> please? Oh, can you keep it simple please, I haven't touched Access
>>>>> for 6 or 7 years.


 
Reply With Quote
 
Keith Willcocks
Guest
Posts: n/a
 
      22nd Jul 2007
Oh dear. I was fine with the old 95 version, it's this new fangled stuff
that's messing me up. I made the change to Dim rst As DAO Recordset and
now I am getting the old "Compile error: Expected: end of statement"
message. Sorry to be such a pain, your help and forbearance is greatly
appreciated.

Could there be any other References that I need to include (or exclude)?
The ones I have are:

Visual Basic For Applications
Microsoft Access 10 Object Library
OLE Automation
Microsoft ActiveX Data Objects 2.1 Library
Data Object Wizard
Microsoft DAO 3.6 Object Library

Keith Willcocks


"Allen Browne" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Thanks, Arvin.
>
> (It's 1:15am here. They should not let me near the keyboard!)
>
> --
> Allen Browne - Microsoft MVP. Perth, Western Australia
> Tips for Access users - http://allenbrowne.com/tips.html
> Reply to group, rather than allenbrowne at mvps dot org.
>
> "Arvin Meyer [MVP]" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> Allen mean the opposite:
>>
>> Change the line:
>>
>> Dim rst As Recordset
>>
>> to:
>>
>> Dim rst As DAO.Recordset
>> --
>> Arvin Meyer, MCP, MVP
>> http://www.datastrat.com
>> http://www.mvps.org/access
>> http://www.accessmvp.com
>>
>> "Allen Browne" <(E-Mail Removed)> wrote in message
>> news:%(E-Mail Removed)...
>>> Change the line:
>>> Dim rst As DAO.Recordset
>>> to:
>>> Dim rst As Recordset
>>>
>>> The ADO library has a Recordset object as well. If you are getting a
>>> type mismatch, Access might be giving you the wrong one, so the above
>>> disambiguates.
>>>
>>> "Keith Willcocks" <(E-Mail Removed)> wrote in message
>>> news:(E-Mail Removed)...
>>>> Many thanks for that Allen. I have now installed the DAO Library and
>>>> "Database" is now recognised in the Declarations. Curiously though I
>>>> am still getting a Type Mismatch message. This is my actual code if
>>>> you can see anything daft that I cannot see for the trees:
>>>>
>>>> Declaration:
>>>> Dim dbs As Database
>>>> Dim rst As Recordset
>>>> - - - - - - - - - - - - - - - - - - - - - - - - - - - -
>>>> Private Sub cmdIssuesSubmit_Click()
>>>> On Error GoTo Err_cmdIssuesSubmit_Click
>>>> Set dbs = CurrentDb
>>>> Set rst = dbs.OpenRecordset("tblMain")
>>>> rst.MoveFirst
>>>>
>>>> Exit_Err_cmdIssuesSubmit_Click:
>>>> Exit Sub
>>>>
>>>> Err_cmdIssuesSubmit_Click:
>>>> MsgBox Err.Description
>>>> Resume Exit_Err_cmdIssuesSubmit_Click
>>>>
>>>> End Sub
>>>>
>>>> Stepping through in debug with F8, the error message Type Mismatch is
>>>> thrown up as soon as the line Set rst = dbs.OpenRecordset("tblMain")
>>>> is executed. The table has four short date/time fields and all the
>>>> others are Text. There is one record in the table with data in the
>>>> Primary Key (number 1) and Text in the first two Text fields. I have
>>>> rigorously checked all the spellings in the code.
>>>>
>>>> I am totally puzzled by this and can see no reason for it.
>>>>
>>>> Keith Willcocks
>>>>
>>>> "Allen Browne" <(E-Mail Removed)> wrote in message
>>>> news:(E-Mail Removed)...
>>>>> You need to add the DAO library reference:
>>>>> http://allenbrowne.com/ser-38.html
>>>>>
>>>>> "Keith Willcocks" <(E-Mail Removed)> wrote in message
>>>>> news:(E-Mail Removed)...
>>>>>>I used to use Access 95 VBA but now have to do something in Access
>>>>>>2000.
>>>>>>
>>>>>> The following in Declarations:
>>>>>> Dim dbs As Database
>>>>>> Dim rst As Recordset
>>>>>>
>>>>>> Followed in a procedure by:
>>>>>> Set dbs = CurrentDb
>>>>>> Set rst = dbs.OpenRecordset("tblMain")
>>>>>>
>>>>>> Would open the table for use. However, in Access 2000, this simply
>>>>>> results in error messages. As far as I can see the Database option
>>>>>> in "Dim dbs As Database" no longer works and is giving me Type
>>>>>> Mismatch messages. How do I do this operation in Access 2000
>>>>>> please? Oh, can you keep it simple please, I haven't touched
>>>>>> Access for 6 or 7 years.

>



 
Reply With Quote
 
Allen Browne
Guest
Posts: n/a
 
      22nd Jul 2007
What line of code generates the compile error that an endof statement is
expected?

With the DAO 3.6 library referenced, the line:
Dim rst As DAO.Recordset
is valid (assuming you don't have something else named rst.)

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Keith Willcocks" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Oh dear. I was fine with the old 95 version, it's this new fangled stuff
> that's messing me up. I made the change to Dim rst As DAO Recordset and
> now I am getting the old "Compile error: Expected: end of statement"
> message. Sorry to be such a pain, your help and forbearance is greatly
> appreciated.
>
> Could there be any other References that I need to include (or exclude)?
> The ones I have are:
>
> Visual Basic For Applications
> Microsoft Access 10 Object Library
> OLE Automation
> Microsoft ActiveX Data Objects 2.1 Library
> Data Object Wizard
> Microsoft DAO 3.6 Object Library
>
> Keith Willcocks
>
>
> "Allen Browne" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> Thanks, Arvin.
>>
>> (It's 1:15am here. They should not let me near the keyboard!)
>>
>> "Arvin Meyer [MVP]" <(E-Mail Removed)> wrote in message
>> news:(E-Mail Removed)...
>>> Allen mean the opposite:
>>>
>>> Change the line:
>>>
>>> Dim rst As Recordset
>>>
>>> to:
>>>
>>> Dim rst As DAO.Recordset
>>> --
>>> Arvin Meyer, MCP, MVP
>>> http://www.datastrat.com
>>> http://www.mvps.org/access
>>> http://www.accessmvp.com
>>>
>>> "Allen Browne" <(E-Mail Removed)> wrote in message
>>> news:%(E-Mail Removed)...
>>>> Change the line:
>>>> Dim rst As DAO.Recordset
>>>> to:
>>>> Dim rst As Recordset
>>>>
>>>> The ADO library has a Recordset object as well. If you are getting a
>>>> type mismatch, Access might be giving you the wrong one, so the above
>>>> disambiguates.
>>>>
>>>> "Keith Willcocks" <(E-Mail Removed)> wrote in message
>>>> news:(E-Mail Removed)...
>>>>> Many thanks for that Allen. I have now installed the DAO Library and
>>>>> "Database" is now recognised in the Declarations. Curiously though
>>>>> I am still getting a Type Mismatch message. This is my actual code
>>>>> if you can see anything daft that I cannot see for the trees:
>>>>>
>>>>> Declaration:
>>>>> Dim dbs As Database
>>>>> Dim rst As Recordset
>>>>> - - - - - - - - - - - - - - - - - - - - - - - - - - - -
>>>>> Private Sub cmdIssuesSubmit_Click()
>>>>> On Error GoTo Err_cmdIssuesSubmit_Click
>>>>> Set dbs = CurrentDb
>>>>> Set rst = dbs.OpenRecordset("tblMain")
>>>>> rst.MoveFirst
>>>>>
>>>>> Exit_Err_cmdIssuesSubmit_Click:
>>>>> Exit Sub
>>>>>
>>>>> Err_cmdIssuesSubmit_Click:
>>>>> MsgBox Err.Description
>>>>> Resume Exit_Err_cmdIssuesSubmit_Click
>>>>>
>>>>> End Sub
>>>>>
>>>>> Stepping through in debug with F8, the error message Type Mismatch is
>>>>> thrown up as soon as the line Set rst = dbs.OpenRecordset("tblMain")
>>>>> is executed. The table has four short date/time fields and all the
>>>>> others are Text. There is one record in the table with data in the
>>>>> Primary Key (number 1) and Text in the first two Text fields. I have
>>>>> rigorously checked all the spellings in the code.
>>>>>
>>>>> I am totally puzzled by this and can see no reason for it.
>>>>>
>>>>> Keith Willcocks
>>>>>
>>>>> "Allen Browne" <(E-Mail Removed)> wrote in message
>>>>> news:(E-Mail Removed)...
>>>>>> You need to add the DAO library reference:
>>>>>> http://allenbrowne.com/ser-38.html
>>>>>>
>>>>>> "Keith Willcocks" <(E-Mail Removed)> wrote in message
>>>>>> news:(E-Mail Removed)...
>>>>>>>I used to use Access 95 VBA but now have to do something in Access
>>>>>>>2000.
>>>>>>>
>>>>>>> The following in Declarations:
>>>>>>> Dim dbs As Database
>>>>>>> Dim rst As Recordset
>>>>>>>
>>>>>>> Followed in a procedure by:
>>>>>>> Set dbs = CurrentDb
>>>>>>> Set rst = dbs.OpenRecordset("tblMain")
>>>>>>>
>>>>>>> Would open the table for use. However, in Access 2000, this simply
>>>>>>> results in error messages. As far as I can see the Database option
>>>>>>> in "Dim dbs As Database" no longer works and is giving me Type
>>>>>>> Mismatch messages. How do I do this operation in Access 2000
>>>>>>> please? Oh, can you keep it simple please, I haven't touched
>>>>>>> Access for 6 or 7 years.


 
Reply With Quote
 
Keith Willcocks
Guest
Posts: n/a
 
      22nd Jul 2007
I feel such a fool now. It was only in your latest email that my less than
20-20 vision realised there was a full stop (period?) between DAO and
Recordset. Now it works a treat. My most sincere thanks.
--
Keith Willcocks
(If you can't laugh at life, it ain't worth living!)


"Allen Browne" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> What line of code generates the compile error that an endof statement is
> expected?
>
> With the DAO 3.6 library referenced, the line:
> Dim rst As DAO.Recordset
> is valid (assuming you don't have something else named rst.)
>
> --
> Allen Browne - Microsoft MVP. Perth, Western Australia
> Tips for Access users - http://allenbrowne.com/tips.html
> Reply to group, rather than allenbrowne at mvps dot org.
>
> "Keith Willcocks" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> Oh dear. I was fine with the old 95 version, it's this new fangled
>> stuff that's messing me up. I made the change to Dim rst As DAO
>> Recordset and now I am getting the old "Compile error: Expected: end of
>> statement" message. Sorry to be such a pain, your help and forbearance
>> is greatly appreciated.
>>
>> Could there be any other References that I need to include (or exclude)?
>> The ones I have are:
>>
>> Visual Basic For Applications
>> Microsoft Access 10 Object Library
>> OLE Automation
>> Microsoft ActiveX Data Objects 2.1 Library
>> Data Object Wizard
>> Microsoft DAO 3.6 Object Library
>>
>> Keith Willcocks
>>
>>
>> "Allen Browne" <(E-Mail Removed)> wrote in message
>> news:(E-Mail Removed)...
>>> Thanks, Arvin.
>>>
>>> (It's 1:15am here. They should not let me near the keyboard!)
>>>
>>> "Arvin Meyer [MVP]" <(E-Mail Removed)> wrote in message
>>> news:(E-Mail Removed)...
>>>> Allen mean the opposite:
>>>>
>>>> Change the line:
>>>>
>>>> Dim rst As Recordset
>>>>
>>>> to:
>>>>
>>>> Dim rst As DAO.Recordset
>>>> --
>>>> Arvin Meyer, MCP, MVP
>>>> http://www.datastrat.com
>>>> http://www.mvps.org/access
>>>> http://www.accessmvp.com
>>>>
>>>> "Allen Browne" <(E-Mail Removed)> wrote in message
>>>> news:%(E-Mail Removed)...
>>>>> Change the line:
>>>>> Dim rst As DAO.Recordset
>>>>> to:
>>>>> Dim rst As Recordset
>>>>>
>>>>> The ADO library has a Recordset object as well. If you are getting a
>>>>> type mismatch, Access might be giving you the wrong one, so the above
>>>>> disambiguates.
>>>>>
>>>>> "Keith Willcocks" <(E-Mail Removed)> wrote in message
>>>>> news:(E-Mail Removed)...
>>>>>> Many thanks for that Allen. I have now installed the DAO Library
>>>>>> and "Database" is now recognised in the Declarations. Curiously
>>>>>> though I am still getting a Type Mismatch message. This is my
>>>>>> actual code if you can see anything daft that I cannot see for the
>>>>>> trees:
>>>>>>
>>>>>> Declaration:
>>>>>> Dim dbs As Database
>>>>>> Dim rst As Recordset
>>>>>> - - - - - - - - - - - - - - - - - - - - - - - - - - - -
>>>>>> Private Sub cmdIssuesSubmit_Click()
>>>>>> On Error GoTo Err_cmdIssuesSubmit_Click
>>>>>> Set dbs = CurrentDb
>>>>>> Set rst = dbs.OpenRecordset("tblMain")
>>>>>> rst.MoveFirst
>>>>>>
>>>>>> Exit_Err_cmdIssuesSubmit_Click:
>>>>>> Exit Sub
>>>>>>
>>>>>> Err_cmdIssuesSubmit_Click:
>>>>>> MsgBox Err.Description
>>>>>> Resume Exit_Err_cmdIssuesSubmit_Click
>>>>>>
>>>>>> End Sub
>>>>>>
>>>>>> Stepping through in debug with F8, the error message Type Mismatch is
>>>>>> thrown up as soon as the line Set rst = dbs.OpenRecordset("tblMain")
>>>>>> is executed. The table has four short date/time fields and all the
>>>>>> others are Text. There is one record in the table with data in the
>>>>>> Primary Key (number 1) and Text in the first two Text fields. I
>>>>>> have rigorously checked all the spellings in the code.
>>>>>>
>>>>>> I am totally puzzled by this and can see no reason for it.
>>>>>>
>>>>>> Keith Willcocks
>>>>>>
>>>>>> "Allen Browne" <(E-Mail Removed)> wrote in message
>>>>>> news:(E-Mail Removed)...
>>>>>>> You need to add the DAO library reference:
>>>>>>> http://allenbrowne.com/ser-38.html
>>>>>>>
>>>>>>> "Keith Willcocks" <(E-Mail Removed)> wrote in message
>>>>>>> news:(E-Mail Removed)...
>>>>>>>>I used to use Access 95 VBA but now have to do something in Access
>>>>>>>>2000.
>>>>>>>>
>>>>>>>> The following in Declarations:
>>>>>>>> Dim dbs As Database
>>>>>>>> Dim rst As Recordset
>>>>>>>>
>>>>>>>> Followed in a procedure by:
>>>>>>>> Set dbs = CurrentDb
>>>>>>>> Set rst = dbs.OpenRecordset("tblMain")
>>>>>>>>
>>>>>>>> Would open the table for use. However, in Access 2000, this simply
>>>>>>>> results in error messages. As far as I can see the Database
>>>>>>>> option in "Dim dbs As Database" no longer works and is giving me
>>>>>>>> Type Mismatch messages. How do I do this operation in Access
>>>>>>>> 2000 please? Oh, can you keep it simple please, I haven't
>>>>>>>> touched Access for 6 or 7 years.

>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
code works in 2000, won't work in 2007 Angie Microsoft Access VBA Modules 1 29th Oct 2008 07:23 PM
POP reports in 2000-Can't get code to work szag via AccessMonster.com Microsoft Access Reports 5 21st Mar 2006 11:42 AM
Why does this code not work.....(Access 2000) =?Utf-8?B?U0VBTiBESScnJydBTk5P?= Microsoft Access 1 1st Mar 2006 01:28 PM
Why code work in 2003 but not 2000? Job Microsoft Excel Programming 2 12th Jul 2005 07:55 PM
Why does code work in Excel 2000 but not in 2002 =?Utf-8?B?TGEgRHVyYW5kZQ==?= Microsoft Powerpoint 3 17th Sep 2004 05:59 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:42 PM.