|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
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
|
|
#2
|
|||
|
|||
|
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.
|
|
#3
|
|||
|
|||
|
U should add DAO library into your project!
|
|
#4
|
|||
|
|||
|
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. |
|
#5
|
|||
|
|||
|
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 |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > Visual Basic Programming > error in Access 2000 code |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|