?
Solved

VB and DAO

Posted on 2003-03-31
4
Medium Priority
?
144 Views
Last Modified: 2010-05-01
Hi
I have a function AddRecord that is called from another function cmdAboutUsUpdateClick.  
When I run this function within my program I get the following error "Run time Error 13" type mismatch.
Highlighting the sentence Set OurRS = OurDB.OpenRecordset("AboutUsTable", dbOpenTable)
If you could give me any help with this I would be more than thankful.
Sabrina

Private Sub AddRecord(Path As String)
    Dim OurDB As Database
    Set OurDB = OpenDatabase(Path)
    Dim OurRS As Recordset
    'Open the table as a recordset
   
    Set OurRS = OurDB.OpenRecordset("AboutUsTable", dbOpenTable)

    OurRS.AddNew
    OurRS.Fields(0).Value = txtFields(13).Text
    OurRS.Fields(1).Value = txtFields(14).Text
    OurRS.Fields(2).Value = txtFields(15).Text
    OurRS.Update
    OurRS.Close
   
   OurDB.Close
 
End Sub

Private Sub cmdAboutUsUpdate_Click()
    AddRecord (App.Path + "\Grouping1.mdb")
   
End Sub
0
Comment
Question by:saodonnell
4 Comments
 
LVL 1

Expert Comment

by:Barraza
ID: 8242160
Your code seems like it should work.
What references do you have set?
0
 
LVL 70

Accepted Solution

by:
Éric Moreau earned 440 total points
ID: 8242490
declare
Dim OurRS As Recordset
as
Dim OurRS As DAO.Recordset
0
 
LVL 3

Expert Comment

by:sanjaykattimani
ID: 8244197
declare recordset as below

Dim OurRS As New Recordset
0
 

Author Comment

by:saodonnell
ID: 8245166
Excellent it worked straight away...  i would have been there for ages otherwise
Thanks a mil
Sabrina
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses

621 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question