Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

doing more with data controls

Posted on 2000-02-17
3
Medium Priority
?
173 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 60 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

688 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