Solved

doing more with data controls

Posted on 2000-02-17
3
166 Views
Last Modified: 2010-05-02
I have a data control setup on the form with a couple of bounded textboxes. I have two tables in the Access database. The bounded textboxes write directly to one of the tables. But I want to be able to update a record in the other table associated with the current record that was editted.  How do I do this as there seems to be no events for the data control to do this?
0
Comment
Question by:rukiman
3 Comments
 
LVL 2

Expert Comment

by:alokanant
ID: 2530491
hi,
u can write the following code in the Save button of your form.


dim db as database
dim rs as recordset

' write code to open the database containing the other table

set rs = db.openrecordset("select * from OtherTable where relatedfld = '" & txtrelatedfld &"')
rs.edit
rs!fldtoupdate = txtval
....
rs.update
rs.close

hth
alok

hth
alok.
0
 
LVL 2

Accepted Solution

by:
p_biggelaar earned 20 total points
ID: 2531197
The 'normal' (DAO) data control doessn't have those features. The Microsoft Ado Data Control does have events like:

Adodc1_RecordChangeComplete(ByVal adReason As ADODB.EventReasonEnum, ByVal cRecords As Long, ByVal pError As ADODB.Error, adStatus As ADODB.EventStatusEnum, ByVal pRecordset As ADODB.Recordset)
Adodc1_RecordsetChangeComplete(ByVal adReason As ADODB.EventReasonEnum, ByVal pError As ADODB.Error, adStatus As ADODB.EventStatusEnum, ByVal pRecordset As ADODB.Recordset)
Private Sub Adodc1_WillChangeField(ByVal cFields As Long, Fields As Variant, adStatus As ADODB.EventStatusEnum, ByVal pRecordset As ADODB.Recordset)
Private Sub Adodc1_WillChangeRecord(ByVal adReason As ADODB.EventReasonEnum, ByVal cRecords As Long, adStatus As ADODB.EventStatusEnum, ByVal pRecordset As ADODB.Recordset)
Private Sub Adodc1_WillChangeRecordset(ByVal adReason As ADODB.EventReasonEnum, adStatus As ADODB.EventStatusEnum, ByVal pRecordset As ADODB.Recordset)

In other words: using the ADODC will solve your problem.
0
 

Expert Comment

by:tcornett
ID: 2532636
If the fields you want to update are the same, use "Enforce Referential Integrity".  For example, you have Table1 and Table2, both have a field called Index and the two tables are joined by this field.  In Access, create the relationship, choose Enforce Referential Integrity, and then Cascade Update Related Fields.  That way, when you change Index in Table1 from 1 to 2, it does the same in Table2.  By the way, the fields that would be linked must be part of the primary key of each table to use Referential Integrity.

- Tom
0

Featured Post

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question