Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsProgrammingVisual Basic Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old April 4th, 2006, 03:47 PM
evansc evansc is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jul 2004
Posts: 258 evansc User rank is Private First Class (20 - 50 Reputation Level)evansc User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 1 Day 4 m 16 sec
Reputation Power: 5
VBA - connection to server fails - "object is required".

I have an access adp and SQL Server 2000.

I have used code similar to the below many times to make a connection to the server and run a stored procedure. But this time it is telling me that an object is required and blowing up at the .ActiveConnection line.

Can anyone help me figure this one out? Thanks!


Code:
Dim intClaimID As Integer
Dim intPersonID As Integer
Dim intPersonTypeID As Integer

intClaimID = Form_frmClaims.txtClaimID
intPersonID = Me.listPeople.Column(0)
intPersonTypeID = 3

With cmd
        .ActiveConnection = CurrentProject.BaseConnectionString
        .CommandType = adCmdStoredProc
        .CommandText = "CSF_UPDATE_Claim_Person_XREF_T"
        .Parameters.Refresh
        .Parameters(1) = 0  'Need to autoset the Claim_Person_XREF_ID
        .Parameters(2) = intClaimID
        .Parameters(3) = intPersonID
        .Parameters(4) = intPersonTypeID
        .Parameters(5) = 0  'Deleted_B set to zero
        Set rst = .Execute
    End With

Reply With Quote
  #2  
Old April 4th, 2006, 04:53 PM
Doug G Doug G is offline
Grumpier Old Moderator
ASP Free God 11th Plane (10000 - 10499 posts)
 
Join Date: Sep 2003
Posts: 10,143 Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 3 Weeks 4 Days 23 h 19 m 36 sec
Reputation Power: 181
Where do you ever create the cmd object?
__________________
======
Doug G
======
I didn't attend the funeral, but I sent a nice letter saying I approved of it. --Mark Twain

Reply With Quote
  #3  
Old April 5th, 2006, 02:19 PM
evansc evansc is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jul 2004
Posts: 258 evansc User rank is Private First Class (20 - 50 Reputation Level)evansc User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 1 Day 4 m 16 sec
Reputation Power: 5
Gee - don't I feel dumb.

It always helps to actually declare your variables! Thanks for pointing it out. I had just stared at it for so long that I totally missed the obvious.

Reply With Quote
  #4  
Old April 5th, 2006, 06:59 PM
Doug G Doug G is offline
Grumpier Old Moderator
ASP Free God 11th Plane (10000 - 10499 posts)
 
Join Date: Sep 2003
Posts: 10,143 Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 3 Weeks 4 Days 23 h 19 m 36 sec
Reputation Power: 181
I like to use Option Explicit at the top of pages. That way the interpreter alerts you to undeclared variables, mis-spelled variable names and other programming annoyances.

Reply With Quote
  #5  
Old April 6th, 2006, 12:53 PM
evansc evansc is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jul 2004
Posts: 258 evansc User rank is Private First Class (20 - 50 Reputation Level)evansc User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 1 Day 4 m 16 sec
Reputation Power: 5
Thanks for the advice - I didn't know that's what that "Option Explicit" was for. That will help me quite a bit, I think.

Reply With Quote
  #6  
Old April 6th, 2006, 02:27 PM
Doug G Doug G is offline
Grumpier Old Moderator
ASP Free God 11th Plane (10000 - 10499 posts)
 
Join Date: Sep 2003
Posts: 10,143 Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 3 Weeks 4 Days 23 h 19 m 36 sec
Reputation Power: 181

Reply With Quote
Reply

Viewing: ASP Free ForumsProgrammingVisual Basic Programming > VBA - connection to server fails - "object is required".


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway
Stay green...Green IT