Design

  • Thread starter Thread starter Bernadette
  • Start date Start date
B

Bernadette

I have a data base with among others, two fields
called "Lname of Householder1" and "Lname of
Householder2".

When the Lname of Householder1 is entered, I would like
this field to be carried to the "Lname of Householder2"
if there is in fact a Householder2, by using a Lookup or
something, but also want to be able to type in a
different name for Householder2 where there is a defacto
relationship for example.
Any help would be appreciated
..
 
I have a data base with among others, two fields
called "Lname of Householder1" and "Lname of
Householder2".

When the Lname of Householder1 is entered, I would like
this field to be carried to the "Lname of Householder2"
if there is in fact a Householder2, by using a Lookup or
something, but also want to be able to type in a
different name for Householder2 where there is a defacto
relationship for example.
Any help would be appreciated
.

Well, what if there are THREE householders? (Polygamy might be one
such situation, but I know three sisters who share a home). Or four?

You've got a real-world one to many relationship, it seems to me!

That said... you can use the AfterUpdate event of the Form control
bound to [LName Of Householder1]:

Private Sub txtLName1_AfterUpdate()
If IsNull(Me!txtLName2) Then ' don't stomp on existing name
Me!txtLName2 = Me!txtLName1
End If
End Sub

You cannot do this in a table datasheet, but that's just one of many
reasons you should use Forms instead of tables for data entry.

John W. Vinson[MVP]
 
Thanks John; Have tried to write the code which is
accpeted, but shows as 'General' I must be writing the
code incorrectly. It is written as an AfterUpdate in the
properties of the Lname field. Does the word 'TXT' need
to preceed each field name and should I be using any
square brackets [] sorry to be a nuisance but this is
all fairly new to me
Thanks in advance
-----Original Message-----
I have a data base with among others, two fields
called "Lname of Householder1" and "Lname of
Householder2".

When the Lname of Householder1 is entered, I would like
this field to be carried to the "Lname of Householder2"
if there is in fact a Householder2, by using a Lookup or
something, but also want to be able to type in a
different name for Householder2 where there is a defacto
relationship for example.
Any help would be appreciated
.

Well, what if there are THREE householders? (Polygamy might be one
such situation, but I know three sisters who share a home). Or four?

You've got a real-world one to many relationship, it seems to me!

That said... you can use the AfterUpdate event of the Form control
bound to [LName Of Householder1]:

Private Sub txtLName1_AfterUpdate()
If IsNull(Me!txtLName2) Then ' don't stomp on existing name
Me!txtLName2 = Me!txtLName1
End If
End Sub

You cannot do this in a table datasheet, but that's just one of many
reasons you should use Forms instead of tables for data entry.

John W. Vinson[MVP]
.
 
Thanks John; Have tried to write the code which is
accpeted, but shows as 'General' I must be writing the
code incorrectly. It is written as an AfterUpdate in the
properties of the Lname field. Does the word 'TXT' need
to preceed each field name and should I be using any
square brackets [] sorry to be a nuisance but this is
all fairly new to me

Please post the Name properties of the form text boxes and the actual
fieldnames in your table; you might want to alsopost your code.

I was appending txt to the control names out of habit - Access
defaults to naming controls the same as the name of the table field to
which they are bound, but this can get confusing both to the
programmer and to Access, so I'll routinely rename the textbox by
prefixing txt to its name. WHere I have "txtLName2", you should have
the Name property of the control bound to [LName Of Householder 2],
and so on; square brackets never hurt around control or fieldnames,
though they are not required if the name contains no blanks or other
special characters.

John W. Vinson[MVP]
 
Back
Top