|
-
Jun 14th, 2000, 11:03 PM
#1
Thread Starter
New Member
Actualy i'm buinding a form that has 2 data controls linked to two diffrent databases, and I have a dbgrid that is linked to an empty database, I want to add diffrent things from the 2 data controls to the dbgrid, so far, i'm getting no where I was hoping to get in touch with Karl Moore, beacuse of his "world famous" database tutorial. It actuly is easy to learn database with that tutorial.
Please reply or e-mail me with examples or ways I can do this. Thank you..
-
Jun 14th, 2000, 11:12 PM
#2
PowerPoster
Then May be you can add what ever you want from the two data control into the empty database then just refersh your dbgrid.
-
Jun 14th, 2000, 11:22 PM
#3
Thread Starter
New Member
can you give me a code example
i'm not quite sure what your talking about, i understand, but codewise it just does not click in you know...
-
Jun 15th, 2000, 10:34 AM
#4
PowerPoster
Sample Code
Hi Spidie-Man, here is a sample code hope it can help you. 
By the way, the Data1 and Data2 Data Control is useless in my code and I just ignore it.
Code:
Private Sub Form_Load()
'Assume your database name is:
'1. database1.mdb -> tblCustomer .. Fields(ID, Name, Add1, Add2, Telephone)
'2. database2.mdb -> tblOrder .. Fields(ID, Orderno, TotalOrder, Amount)
'3. database3.mdb -> tblFinal .. Fields(ID, Name, Add1, Add2, Telephone, OrderNo, TotalOrder, Amount)
'Initialize all the data control
Data3.DatabaseName = App.Path & "\database3.mdb"
Data3.RecordSource = "tblFinal"
Data3.Refresh
End Sub
Private Sub cmdCombine_Click()
Dim Db As DAO.Database
Dim MySql As String
Set Db = DBEngine.Workspaces(0).OpenDatabase(App.Path & "\database3.mdb", False, False)
Db.Execute "DELETE * FROM tblFinal;"
'Copy all the records from database1 and database2 into database3
MySql = "INSERT INTO tblFinal (ID, Name, Add1, Add2, Telephone, OrderNo, TotalOrder, Amount) " & _
"SELECT tblCustomer.ID, Name, Add1, Add2, Telephone, OrderNo, TotalOrder, Amount FROM [" & App.Path & "\database1.mdb].tblCustomer LEFT JOIN [" & App.Path & "\database2.mdb].tblOrder " & _
"ON tblCustomer.ID = tblOrder.ID " & _
"ORDER BY tblCustomer.ID ASC;"
Db.Execute MySql
Db.Close
Set Db = Nothing
Data3.Refresh
End Sub
[Edited by Chris on 06-16-2000 at 07:40 AM]
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|