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!

Another ADO Headache!

Status
Not open for further replies.

lulo

Programmer
Jan 24, 2001
51
0
0
US
This is first app using ADO, previously using DAO.
I have 3 linked tables in an open connection, when I add a new record information from link tables don't show.

What am I doing wrong?
ON DAO whe you add a new record it immediately updates the related field for to the link table. This a very valuable feature on DAO, now Can I do this on ADO?

This is my code:
Public Train_Conn As New ADODB.Connection
Public gRDB_RS As ADODB.Recordset

sNewConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=Z:\GlobalApps\Training\Training.mdb;Persist Security Info=False"
Train_Conn.ConnectionString = sNewConnectionString
Train_Conn.CursorLocation = adUseServer
Train_Conn.Mode = adModeReadWrite
Train_Conn.Open

Set gRDB_RS = New ADODB.Recordset
gRDB_RS.Open stgSQL, Train_Conn, _
adOpenKeyset, _
adLockOptimistic

'After connection opens

If cmbProcess.ListIndex <> 0 Then
gRDB_RS.Filter = &quot;SheetID=&quot; & cmbProcess.ItemData(cmbProcess.ListIndex)
Else
gRDB_RS.Filter = adFilterNone
End If
Set gTRAIN.DataSource = gRDB_RS

'Where gTrain is a grid.

Thanks for your help guys.

Lulo
 
You can do one of to things to update the data. You can use the rs.Update method or you can just move to another record with any of the Move methods. Is that what you are asking? If you choose to battle wits with the witless be prepared to lose.
[machinegun][hammer]
 
Yes after I use rs.Update it adds a new record but related info from other tables won't show, example

I enter EmployeeID and other info on current table as soon as I update EmployeeID I should get EmployeeName, EmployeeSS, EmployeeTitle, Etc. from my related table.

This is the way it works on DAO.

Thanks for your help foada.

Lulo
 
Maybe I am not understanding what you are asking. Does the database not update or the form's display? If it is the forms display what are you using to display the data and is it bound? If you choose to battle wits with the witless be prepared to lose.
[machinegun][hammer]
 
Ok let me explain myself.
I adopted to use this method because it works fine for me.

First, I load the entire database.
sNewConnectionString
Conn.ConnectionString = sNewConnectionString
Conn.CursorLocation = adUseServer
Conn.Mode = adModeReadWrite
Conn.Open

Second, I open the recordset for related tables.
Set gRDB_RS = New ADODB.Recordset
gRDB_RS.Open stgSQL, Train_Conn, _
adOpenKeyset, _
adLockOptimistic

Third, I bound this recordset to a grid (grid read-only)
Set grid.DataSource = gRDB_RS

When I click on a row(grid) I find that record on that
row(grid) in the recordset to view that record info.

Now, when I add a new record in the recordset it should also update other related fields, but it doesn't.




 
It will update if you write the code in Access and use relationships? In vb you have to manage this yourself I think. I never use relationships, so I'm not absolutely sure here. Peter Meachem
peter @ accuflight.com

 
yes Peter, on a acces query it does all the work. Also using DAO does it which is what I have always used.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top