Welcome to Dream.In.Code
Become a VB Expert!

Join 137,230 VB Programmers for FREE! Get instant access to thousands of VB experts, tutorials, code snippets, and more! There are 1,855 people online right now. Registration is fast and FREE... Join Now!




Visual Basic, code problem

 
Reply to this topicStart new topic

Visual Basic, code problem

KillerDealer
20 Mar, 2007 - 04:32 AM
Post #1

New D.I.C Head
*

Joined: 20 Mar, 2007
Posts: 1


My Contributions
I keep having this problem and i dont know how to fix this, but i will explain the problem. A started making a DB in VB with ado 6.0, and i had some compatibility problems, anyways i fixed this (i read somewhere to untick dao or somthing like that). Anyways that worked all good, now i want to create my program using DAO but the problem is it disapeared from my components, so i dont have dao only ado. My friend sent me his program which is all linked by codes and when i run it , it all works. But when i try make my own i get an error.

So i make a new form, and i type this code in.

CODE

Option Explicit
'
Dim dbMyDB As Database
Dim rsMyRS As RecordSet

Private Sub Form_Load()

Set dbMyDB = OpenDatabase("I:\MyDatabase.md...
Set rsMyRS = dbMyDB.OpenRecordSet("MyTable"... dbOpenDynaset)

If Not rsMyRS.EOF Then rsMyRS.MoveFirst
Do While Not rsMyRS.EOF
lstRecords.AddItem rsMyRS!Name
lstRecords.ItemData(lstRecords... = rsMyRS!ID
rsMyRS.MoveNext
Loop

End Sub

whenever i try to run it says compiler error and it highlights this "dbMyDB As Database" anyone know why sad.gif?

EDIT : Code Tags Added -b2c-
User is offlineProfile CardPM
+Quote Post

jjuneau
RE: Visual Basic, Code Problem
20 Mar, 2007 - 03:14 PM
Post #2

New D.I.C Head
*

Joined: 15 Feb, 2007
Posts: 16


My Contributions
I could be wrong here but your IF..Then statement is improperly formatted. It should be as follows:

If (condition) Then
(code)
End IF


You have it as:

IF (condition) Then (code)
User is offlineProfile CardPM
+Quote Post

m2s87
RE: Visual Basic, Code Problem
20 Mar, 2007 - 05:35 PM
Post #3

D.I.C Regular
Group Icon

Joined: 28 Nov, 2006
Posts: 390



Thanked: 1 times
Dream Kudos: 1225
My Contributions
QUOTE(KillerDealer @ 20 Mar, 2007 - 02:32 PM) *

CODE
Dim dbMyDB As Database
Dim rsMyRS As RecordSet



Should thay not be
CODE
Dim dbMyDB As new Connection
Dim rsMyRS As new RecordSet

User is offlineProfile CardPM
+Quote Post

born2c0de
RE: Visual Basic, Code Problem
20 Mar, 2007 - 10:45 PM
Post #4

printf("I'm a %XR",195936478);
Group Icon

Joined: 26 Nov, 2004
Posts: 3,914



Thanked: 34 times
Dream Kudos: 2800
Expert In: 80x86 Assembly, C/C++, VB6, VB.NET, C#, J2SE, Win32 API, Reversing

My Contributions
Maybe you haven't included Microsoft ActiveX Data Objects as a reference.
Include it as a reference from the object browser.

And as m2s87 mentioned, 'Database' should be replaced with 'Connection'
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 12/4/08 03:18PM

Live VB Help!

VB Tutorials

Reference Sheets

VB Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month