Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreVisual 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 Dev Shed Forums Sponsor:
  #1  
Old October 12th, 2003, 09:53 PM
linh linh is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2003
Posts: 245 linh User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 11 m 27 sec
Reputation Power: 6
error in Access 2000 code

Access 2000 form. When I clicked on the button, it gives me a run-time error 91

=================================
run-time error 91
Object variable or With block variable not set.

The statement below was highlighted

Set RecordSet_Customer = Dbs.OpenRecordset("Customer", dbOpenTable)

================================
Code:
Private Sub Command15_Click()

    Dim Dbs As Database
    Dim RecordSet_Customer As Recordset

    Set RecordSet_Customer = Dbs.OpenRecordset("Customer", dbOpenTable)
    Set Dbs = CurrentDb
    
    Dim Tenant_Number_Temp As String
    Dim Unit_Number_Temp As String
    Dim Last_Name_Temp As String
    Dim First_Name_Temp As String
    Dim counter As Long
    
    Tenant_Number_Temp = "T-100-11-2-1999"
    Unit_Number_Temp = "1000"
    Last_Name_Temp = "Sacramento"
    First_Name_Temp = "Jayson and John"
    counter = 0
    
    Do While counter < 10
        counter = counter + 1
        Text_10.SetFocus
        Text_10.Text = counter
        With RecordSet_Customer
           .AddNew
             !Tenant_Number = "T-100-11-2-1999"
             !Unit_Number = "10000"
             !Last_Name = "Sacramento"
             !First_Name = "Jayson and John"
             RecordSet_Customer.Update
        End With
    Loop
    MsgBox "The loop made " & counter & " repetitions."

End Sub

Reply With Quote
  #2  
Old October 12th, 2003, 11:10 PM
Doug G Doug G is offline
Grumpier Old Moderator
Dev Shed God 12th Plane (10500 - 10999 posts)
 
Join Date: Jun 2003
Posts: 10,976 Doug G User rank is Major General (70000 - 90000 Reputation Level)Doug G User rank is Major General (70000 - 90000 Reputation Level)Doug G User rank is Major General (70000 - 90000 Reputation Level)Doug G User rank is Major General (70000 - 90000 Reputation Level)Doug G User rank is Major General (70000 - 90000 Reputation Level)Doug G User rank is Major General (70000 - 90000 Reputation Level)Doug G User rank is Major General (70000 - 90000 Reputation Level)Doug G User rank is Major General (70000 - 90000 Reputation Level)Doug G User rank is Major General (70000 - 90000 Reputation Level)Doug G User rank is Major General (70000 - 90000 Reputation Level)Doug G User rank is Major General (70000 - 90000 Reputation Level)Doug G User rank is Major General (70000 - 90000 Reputation Level)Doug G User rank is Major General (70000 - 90000 Reputation Level)Doug G User rank is Major General (70000 - 90000 Reputation Level) 
Time spent in forums: 1 Month 1 Day 17 h 59 m 48 sec
Reputation Power: 802
You probably need to add a reference to the DAO library in your code. In the VB editor, Tools, References find and add the DAO library. I don't use DAO so I'm not sure what version you might need.

Reply With Quote
  #3  
Old October 13th, 2003, 12:56 AM
cleverpig cleverpig is offline
Contributing User
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Jul 2003
Posts: 1,152 cleverpig User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Send a message via MSN to cleverpig
U should add DAO library into your project!

Reply With Quote
  #4  
Old October 13th, 2003, 09:35 AM
linh linh is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2003
Posts: 245 linh User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 11 m 27 sec
Reputation Power: 6
reply

Hi Doug G and cleverpig

I did add the DAO library, but it still gives me the same error mesage.

Last edited by linh : October 13th, 2003 at 09:38 AM.

Reply With Quote
  #5  
Old October 13th, 2003, 10:14 AM
cleverpig cleverpig is offline
Contributing User
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Jul 2003
Posts: 1,152 cleverpig User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Send a message via MSN to cleverpig
Look it ,maybe it is helpful to U:
OpenRecordset Method Example

This example uses the OpenRecordset method to open five different Recordset objects and display their contents. The OpenRecordsetOutput procedure is required for this procedure to run.

Sub OpenRecordsetX()

Dim wrkJet As Workspace
Dim wrkODBC As Workspace
Dim dbsNorthwind As Database
Dim conPubs As Connection
Dim rstTemp As Recordset
Dim rstTemp2 As Recordset

' Open Microsoft Jet and ODBCDirect workspaces, Microsoft
' Jet database, and ODBCDirect connection.
Set wrkJet = CreateWorkspace("", "admin", "", dbUseJet)
Set wrkODBC = CreateWorkspace("", "admin", "", dbUseODBC)
Set dbsNorthwind = wrkJet.OpenDatabase("Northwind.mdb")
Set conPubs = wrkODBC.OpenConnection("", , , _
"ODBC;DATABASE=pubs;UID=sa;PWD=;DSN=Publishers")

' Open five different Recordset objects and display the
' contents of each.

Debug.Print "Opening forward-only-type recordset " & _
"where the source is a QueryDef object..."
Set rstTemp = dbsNorthwind.OpenRecordset( _
"Ten Most Expensive Products", dbOpenForwardOnly)
OpenRecordsetOutput rstTemp

Debug.Print "Opening read-only dynaset-type " & _
"recordset where the source is an SQL statement..."
Set rstTemp = dbsNorthwind.OpenRecordset( _
"SELECT * FROM Employees", dbOpenDynaset, dbReadOnly)
OpenRecordsetOutput rstTemp

' Use the Filter property to retrieve only certain
' records with the next OpenRecordset call.
Debug.Print "Opening recordset from existing " & _
"Recordset object to filter records..."
rstTemp.Filter = "LastName >= 'M'"
Set rstTemp2 = rstTemp.OpenRecordset()
OpenRecordsetOutput rstTemp2

Debug.Print "Opening dynamic-type recordset from " & _
"an ODBC connection..."
Set rstTemp = conPubs.OpenRecordset( _
"SELECT * FROM stores", dbOpenDynamic)
OpenRecordsetOutput rstTemp

' Use the StillExecuting property to determine when the
' Recordset is ready for manipulation.
Debug.Print "Opening snapshot-type recordset based " & _
"on asynchronous query to ODBC connection..."
Set rstTemp = conPubs.OpenRecordset("publishers", _
dbOpenSnapshot, dbRunAsync)
Do While rstTemp.StillExecuting
Debug.Print " [still executing...]"
Loop
OpenRecordsetOutput rstTemp

rstTemp.Close
dbsNorthwind.Close
conPubs.Close
wrkJet.Close
wrkODBC.Close

End Sub

Sub OpenRecordsetOutput(rstOutput As Recordset)

' Enumerate the specified Recordset object.
With rstOutput
Do While Not .EOF
Debug.Print , .Fields(0), .Fields(1)
.MoveNext
Loop
End With

End Sub

http://msdn.microsoft.com/library/d...enrecordset.asp

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming > error in Access 2000 code


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