Form Issue

millertimecu32

Registered User.
Local time
Today, 04:47
Joined
May 2, 2007
Messages
30
Ok..... next issue i am buiding a form that has a field that the data in the field is always associated with data from another field. ex....

A B
XYZ XXXXX
ABC AAAAA
XYZ XXXXX
ABC AAAAA

My question is how do i make them dependent of each other. So if i enter in one the other is automatically populated.

There is a look up table associated (one look up table with two fields) with the form.
 
Code:
If Me!txtControlName = "AAA" Then
   Me!txtOtherControlName = "111"
ElseIf Me!txtControlName = "BBB" Then
   Me!txtOtherControlName = "222"
Else
   Me!txtOtherControlName = "I don't know."
End if

Or
Code:
Select Case Me!txtControlName
Case "AAA"
   Me!txtOtherControlName = "111"
Case "BBB"
   Me!txtOtherControlName = "222"
Case Else
   Me!txtOtherControlName = "I don't know."
End Select

-dK
 
Ok I am lost...... Where do i enter the code....... i guess you could say that i am out in left field.
 
On the form, go to the control (that you want to influence the other control's data).

On the properties of that control, click the AfterUpdate() event and it will open the visual basic editor. Place it in there.

-dK
 
Can you explain what is happening line by line ...

Select Case Me!txtControlName
Case "AAA"
Me!txtOtherControlName = "111"
Case "BBB"
Me!txtOtherControlName = "222"
Case Else
Me!txtOtherControlName = "I don't know."
End Select
 
I based my response on your requirement that if you wanted to do something in one control, it would make something happen in another control.

First the system automates something on the AfterUpdate() event, in this scenario - of the control. This event is triggered when the control is updated.

So the trigger happens and the system looks at the first line of the Select Case statement ...

Select Case Me!txtControlName

The txtControlName is the name of the control that you just updated. It loads that value into memory and then starts comparing it.

The first comparison is ... Case "AAA". If you changed the control to say AAA then it will execute the next line ...

Me!txtOtherControlName = "111"

The system updates txtOtherControlName (the one you want something to happen in) to display 111.

It goes through each Case statement looking for matches. If it doesn't find one, it executes the Case Else statement telling you "I don't know".

Here are some more links to help you along through tasks like these ...

http://www.techonthenet.com/access/index.php
http://www.sienaheights.edu/personal/csstrain/Access2007.htm
http://www.functionx.com/vbaccess/

-dK
 

Users who are viewing this thread

Back
Top Bottom