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.
>