?
Solved

VB and DAO

Posted on 2003-03-31
4
Medium Priority
?
143 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…
Suggested Courses
Course of the Month12 days, 1 hour left to enroll

752 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