Solved

Access VBA SQL error

Posted on 2011-09-15
7
345 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
  • 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
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

746 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now