dbTalk Databases Forums  

VBA - rst.Open cmd goes to error handling

comp.databases.ms-access comp.databases.ms-access


Discuss VBA - rst.Open cmd goes to error handling in the comp.databases.ms-access forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Inquisitive1
 
Posts: n/a

Default VBA - rst.Open cmd goes to error handling - 04-12-2010 , 09:04 AM






I have some code that works properly in one database that I have
pulled into another database, but it does not work in the other
database. I am not experienced enough to resolve the issue. I have
a
feeling that it has to do with references, but I am at a loss at how
to fix it. I did make the references match in the new database, but
that did not fix the problem (there is code that uses both ADO and
DAO). I would greatly appreiciate any
assistance!!

The Available references selected (in priority order) in the database
where the code IS NOT working are below.
Visual Basic For Applications
Microsoft Access 11.0 Object Library
Mircrosoft Excel 11.0 Object Library
OLE Automation
Microsoft ADO Ext. 2.8 for DDL and Security
Microsoft ActiveX Data Objects 2.1 Library
Microsoft DAO 3.6 Object Library


The Available references selected (in priority order) in the database
where the code IS working are below.
Visual Basic For Applications
Microsoft Access 11.0 Object Library
Microsoft ActiveX Data Objects 2.1 Library
OLE Automation
Microsoft ADO Ext. 2.8 for DDL and Security
Microsoft DAO 3.6 Object Library


Here is the code:


Option Compare Database
Option Explicit
Dim sQueryName As String
---------------------------------------------------------------------------*----------
Public Function ConfirmCertStatus()
DoCmd.SetWarnings False


If ValidCertStat() Then
DoCmd.RunMacro "mcr_SCL_CustomStatusProcessing"
Else
DoCmd.Hourglass False
MsgBox "An unknown cert status has been provided.",
vbInformation, "Unknown Certification Status"
End If
DoCmd.Hourglass False


End Function
---------------------------------------------------------------------------*----------
Private Function ValidCertStat() As Boolean


On Error GoTo Err_ValidCertStat


Dim cmd As ADODB.Command
Dim rst As ADODB.Recordset
Dim prm As ADODB.Parameter


ValidCertStat = True


DoCmd.SetWarnings False


sQueryName = "1-UnknownCertStatusInSCLUpdateHistory"


Set rst = New Recordset
rst.CursorLocation = adUseClient
rst.CursorType = adOpenDynamic


Set cmd = New Command
cmd.ActiveConnection = CurrentProject.Connection
cmd.CommandText = sQueryName
cmd.CommandType = adCmdTable


rst.Open cmd


If rst.RecordCount > 0 Then
ValidCertStat = False
End If


rst.Close
Set rst = Nothing
Set cmd = Nothing


Exit_ValidCertStat:
Exit Function


Err_ValidCertStat:
ValidCertStat = False
Resume Exit_ValidCertStat


End Function

Reply With Quote
  #2  
Old   
Rich P
 
Posts: n/a

Default Re: VBA - rst.Open cmd goes to error handling - 04-12-2010 , 10:23 AM






you need to update MDAC

Quote:
Microsoft ActiveX Data Objects 2.1 Library
to Microsoft ActiveX Data Objects 2.5 Library or higher

Here is an article that focuses on MDAC 2.6

http://www.pcreview.co.uk/forums/thread-1697291.php

You can also download MDAC 2.6 from here (I believe)

HTH


Rich

*** Sent via Developersdex http://www.developersdex.com ***

Reply With Quote
  #3  
Old   
Inquisitive1
 
Posts: n/a

Default Re: VBA - rst.Open cmd goes to error handling - 04-12-2010 , 01:06 PM



On Apr 12, 11:23*am, Rich P <rpng... (AT) aol (DOT) com> wrote:
Quote:
you need to update MDAC

Microsoft ActiveX Data Objects 2.1 Library

to Microsoft ActiveX Data Objects 2.5 Library or higher

Here is an article that focuses on MDAC 2.6

http://www.pcreview.co.uk/forums/thread-1697291.php

You can also download MDAC 2.6 from here (I believe)

HTH

Rich

*** Sent via Developersdexhttp://www.developersdex.com***
Rich,

That did not work. I left everything the same and changed the query
name by removing the "1-". Everything works fine now. Why is it that
the code runs when the query/table name does not begin with a number?
This is very odd.

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.