Click to See Complete Forum and Search --> : Different Tables
Kristo
Sep 18th, 2000, 05:40 PM
I got a PROBLEM about ADO ...
Let's put this scenario:
I got the following Tables:
o Clients
o Orders
o Details
o Credit
o Payments
Also I got a form with SSTAB with all the text boxes Required to bind info or make data entry.
So ... Every time when the user open his application, He gonna get all the clients Assing to him.
The problem is about how to update, add information but to the different tables ... So I'm confused about how I can get this done.
Any recomendation is Welcome
Thanx
JHausmann
Sep 19th, 2000, 03:57 PM
Make a data control, to bind, for every table you need to get/put data to (if you're using bound controls) _or_ retrieve the data from each table and populate the unbound fields...
Kristo
Sep 19th, 2000, 05:59 PM
Ok ... Thanks for the recommendation, anyway do u have a little example to get clear the idea?
The other thing I forgot to mention is, I'm using SQL server 7, Stored procedures will help in this case?
Gracias :)
[Edited by Kristo on 09-19-2000 at 07:01 PM]
HaxSoft
Sep 27th, 2000, 03:30 PM
If you have info in some variables, which we call strSomething:
Dim db As Database
Dim rs As Recordset
Set db = OpenDatabase("mydb.mdb") ' open database
Set rs = db.OpenRecordset("Clients") ' open table
With rs
'*** Add a record...
.Add
!FirstName = strFirstName ' set FirstName field in table
!LastName = strLastName
!PhoneNo = strPhoneNo
strID = !ID ' << get ID from new record (counter field)
.Update ' << store the data
End With
rs.Close
Set rs = db.OpenRecordset("Orders")
With rs
'*** Add record to order...
.Add
!OrderDate = Now() ' order date
!CustomerKey = strID ' Foreign key to Clients table
'
' more stuff here
'
strID = !ID ' get order ID if you need it
.Update
End With
rs.Close ' close table and DB...
db.Close
Set rs = Nothing ' not really needed I think, but still...
Set db = Nothing
This is an example using DAO ... ADO is probably pretty much the same.
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.