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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Creating a relationship in Access 2000 with VB6

Status
Not open for further replies.

gwar2k1

Programmer
Apr 17, 2003
387
GB
Hey, Im having troubles setting up relations using keys in Access 2000. This is the code i have:

Dim FolderRelation As New Relation
'FolderRelation.ForeignTable = DbaseCat.Tables("Customer")
'FolderRelation.Table = DbaseCat.Tables("CustomerProduct")
FolderRelation.Name = "Order"
'FolderRelation.Fields.Append "Folder"

Everything is commented out because at run time it says "Type miss match error" So im stumped, how can it be a type error when the variable is set as a relation?

Im probabally doing this totally wrong as Im doing it without direction and I cant find a good tutorial online, hence the numerous questions on this board.

If it helps:

I have 3 entities: Product, Customer, CustomerProduct
Product has a primary key: "EAN 8/13"
Customer has a primary key: "Folder"
CustomerProduct has a compound key: "Order ID", "Folder", "Product"

CustomerProduct resolves a many to many relationship so customer and product both go one to many to customerproduct

A point in the right direction would be nice =)

TIA

~*Gwar3k1*~
"To the pressure, everything's just like: an illusion. I'll be losing you before long..."
 
Well, first off, I'm not clear whether you're trying to use Access 2000 or VB6. If you're using VB6, read up on the Data Environment. You can use it to create relations.

The way I do it (if I have to use Access instead of SQL Server) is to go into Access and create relations in the user environment there. The only reason to use code to do it is if the relationships change dynamically as your program runs; I've never found occasion to do that.

HTH

Bob
 
im trying to do it in VB6. Im creating the catalogue file via vb6 and all thats left to to setup the relationships

~*Gwar3k1*~
"To the pressure, everything's just like: an illusion. I'll be losing you before long..."
 
Well, you can look at either of two object libraries: if you're using DAO, read up on the Relation object. If you're using ADO, you'll need to read up on ADOX, in particular the Keys collection of the Table object thereof.

HTH

Bob
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top