Association

  • Thread starter Thread starter G
  • Start date Start date
G

G

Hi.
I am using Access 2000.
I have a table called tbl Units.
There are many fields in the table but the ones in particular that I am
concerned about are:

Dem Numb
FName
SName

I have a form called frm Main.
The form has the three fields (and other fields) mentioned above.
Question: I would like to somehow associate a particular Dem Numb to person.
eg. When a person begins to enter data in the form, it would be great if by
simply entering the Dem Num - the FName and the SName are automatically
populated with the person's name which corresponds to the Dem Numb.
Any help would be apprciated.
 
hi,
I hope you are not using spaces in your object names.
see this site for all the no-no characters.
http://support.microsoft.com/?id=826763
as to your question....DLookup. in the DemNumb's before
update event put a sub something like this...
Private Sub txtDemNumb_BeforeUpdate(Cancel As Integer)
If IsNull(Me!txtItemID) Then
Cancel = True

Else

Me!txtFName = DLookup
("[FName]", "tblUnits", "[DemNumb] ='" & Me!txtDemNumb
& "'")
Me!txtSName = DLookup
("[SName]", "tblUnits", "[DemNumb] ='" & Me!txtDemNumb
& "'")

End If

End Sub
note: the DLookup lines wrapped. should be one line
instead of 3.
 
hi again,
opps. make a mistake. i copied a sub i use and edited it
a little for you. instead of starting the sub with
If IsNull(Me!txtItemID) Then
start it
If IsNull(Me!txtDemNumb) Then
sorry about that.
-----Original Message-----
hi,
I hope you are not using spaces in your object names.
see this site for all the no-no characters.
http://support.microsoft.com/?id=826763
as to your question....DLookup. in the DemNumb's before
update event put a sub something like this...
Private Sub txtDemNumb_BeforeUpdate(Cancel As Integer)
If IsNull(Me!txtItemID) Then
Cancel = True

Else

Me!txtFName = DLookup
("[FName]", "tblUnits", "[DemNumb] ='" & Me!txtDemNumb
& "'")
Me!txtSName = DLookup
("[SName]", "tblUnits", "[DemNumb] ='" & Me!txtDemNumb
& "'")

End If

End Sub
note: the DLookup lines wrapped. should be one line
instead of 3.
-----Original Message-----
Hi.
I am using Access 2000.
I have a table called tbl Units.
There are many fields in the table but the ones in particular that I am
concerned about are:

Dem Numb
FName
SName

I have a form called frm Main.
The form has the three fields (and other fields) mentioned above.
Question: I would like to somehow associate a
particular
Dem Numb to person.
eg. When a person begins to enter data in the form, it would be great if by
simply entering the Dem Num - the FName and the SName are automatically
populated with the person's name which corresponds to the Dem Numb.
Any help would be apprciated.


.
.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top