Solved

Access VBA SQL error

Posted on 2011-09-15
7
350 Views
Last Modified: 2012-05-12
Using this code but get an error (See below)
Sql = "SELECT tbl_Inventory.InternalKeyNumber "
Sql = Sql & "FROM tbl_Inventory "
Sql = Sql & "WHERE tbl_Inventory.InternalKeyNumber = " & Ser

Set rst = Dbs.OpenRecordset(Sql)
    If rst.RecordCount = 0 Then
    MsgBox "Invalid Serial Number. Please try again"
    Exit Sub
    End If

ERROR:
 "You mus use dbseechanges with openrecordset when accessing SQL server table that has an identity column"
0
Comment
Question by:HKFuey
[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
  • 3
7 Comments
 
LVL 61

Expert Comment

by:mbizup
ID: 36542153
Use this instead:

Set rst = db.OpenRecordset(sQL,dbOpenDynaset, dbSeeChanges)
0
 
LVL 61

Accepted Solution

by:
mbizup earned 500 total points
ID: 36542155
Sorry...

Set rst = dbs.OpenRecordset(sQL,dbOpenDynaset, dbSeeChanges)
0
 

Author Comment

by:HKFuey
ID: 36542163
Hi mbizup

I get "Object Required error"
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:HKFuey
ID: 36542166
I got it thanks
needs to be Dbs!!
0
 
LVL 61

Expert Comment

by:mbizup
ID: 36542169
Do you have DBS defined anywhere?

Dim dbs as Database
Set dbs = CurrentDB
0
 
LVL 61

Expert Comment

by:mbizup
ID: 36542172
:-)
0
 

Author Closing Comment

by:HKFuey
ID: 36542174
Superb! thanks!!!
0

Featured Post

Why You Need a DevOps Toolchain

IT needs to deliver services with more agility and velocity. IT must roll out application features and innovations faster to keep up with customer demands, which is where a DevOps toolchain steps in. View the infographic to see why you need a DevOps toolchain.

Question has a verified solution.

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

In this article we will learn how to fix  “Cannot install SQL Server 2014 Service Pack 2: Unable to install windows installer msi file” error ?
Access custom database properties are useful for storing miscellaneous bits of information in a format that persists through database closing and reopening.  This article shows how to create and use them.
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.

732 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