Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Why the Database Object is not included in VBA Access 2000

Status
Not open for further replies.

bestbefore99

IS-IT--Management
Jan 24, 2002
16
0
0
IT
I know the question is stupid, and I know the answer is simple, but unfortunately I have been navigating for two days the Internet and the VBA sites without success.

I am simply trying to read records from several tables (Accounting Data, Price Lists, etc) from a local Access Database used for Billing new generation 3G Services apply some rating function and write back to a new table (Rated information)

The probleme is that

1) My version of VBA does not know the "Database Object"
2) Even if I make a work around such as

Dim rs1 As ADODB.Recordset ' Set rs as recordset
Set rs1 = CurrentDb.OpenRecordset("UnratedCDR", dbOpenDynaset)

I get an error message.

What's wrong?

Max (Old Programmer , unfit now)
 
Try this:
Dim MyDb as DAO.Database, rs1 As DAO.Recordset
Set mydb= currentdb
Set rs1 = mydb.OpenRecordset("UnratedCDR", dbOpenDynaset)

This should do the trick
 
Private Sub Form_Current()
Dim db As DAO.Database, rs As DAO.Recordset


Set db = CurrentDb()
Set rs = db.OpenRecordset("Table2")
If rs.EOF And rs.BOF Then Exit Sub
rs.MoveLast ' to populate the recordset
rs.MoveFirst ' bac to top
Do While Not rs.EOF
If rs![OneID] = Me.ID Then GoTo findr:
rs.MoveNext
Loop
GoTo outen:
findr:
'MsgBox Me.Name
Me.Text6.Value = rs![T2field1]
Me.Text8 = rs![T2field2]
outen:
rs.Close
Set rs = Nothing
db.Close
Set db = Nothing

End Sub

Try this.

Rollie E
rollie@bwsys.net
 
I think one of the issues is that you're mixing ADO and DAO objects:

Your's is this:

Dim rs1 As ADODB.Recordset ' Set rs as recordset
Set rs1 = CurrentDb.OpenRecordset("UnratedCDR", dbOpenDynaset)

++++++++++++++++++++++++++++++++++++++++++++++++++
Try this:

Dim rs1 As ADODB.Recordset
Dim conn as ADODB.Connection
Set rs1 = New ADODB.Recordset
Set conn = CurrentProject.Connection

rs1.Open "UnratedCDR", conn, adOpenDynamic, adLockPessimistic


This should work.

Good Luck!
John Pasko
john@rts-sd.com
"No matter where you go, there you are."
 
Try referencing the Microsoft DAO 3.6 Object Library. (Tools, Reference, then select Microsoft DAO 3.6 Object Library)

Good luck!

Morcelli
 
Max
This is a great example of the good use and benefit of forums. I was stuck with this problem in the past for a long time and took ages to sort it out until someone pointed out the ADO/DAO conflicts. Even when knowing the answer, I can't find any indication in Help that would help solve the problem.


I'm not normally a Microsoft knocker but what a wonderful choice of mnemonic for the new generation - at least .net is completely different!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top