lose focus? copy

M

mark r

on a form I have two fields. the first is ssn and the second we'll call mmm.
mmm is 90% populated with the same data entry as ssn but not 100%. so the
user is double inputing teh data into mmm 90% of the time.

As soon as the user inputs data into ssn field, I think mmm should "copy" or
"default" to whatever was typed into ssn. Then 10% of the time the user can
retype and change mmm.

How can I code "a copy" so that when the user leaves the ssn field, mmm
copies ssn? WHERE DO I PLACE THE CODE in CODE BUILDER?

skeleton?

ssn losefocus
let mmm = ssn

?
 
M

mark r

if I change ! to . and mmm# to mmm_ the code works

why?

tina said:
i wonder how "Cancel As Integer" would get into the Arguments section of an
AfterUpdate event procedure in the first place. the AfterUpdate event does
not have a Cancel argument, either on a control or on the form. my
suggestion would be the same as Ofer's, except i might add an If statement
so that the [mmm] value is not overwritten if it already exists, as

Private Sub ssn_AfterUpdate()

If IsNull(Me!mmm) Then
Me!mmm = Me!ssn
End If

End Sub

make sure you're using the correct names of the controls that fields ssn and
mmm are bound to. (btw, do you work for Campbell's Soup? <g> )

hth


mark r said:
wait a minute...........

I took cancel as integer out of parens in Afterupdate(Cancel as Integer)
and then I got a compile error
 
T

tina

well, special characters in field and object names are a real problem when
you're writing VBA code, as you've discovered. personally, i make a point of
never using anything except alpha characters and underscores in *anything* i
name in a database. using brackets around a "strange" name might work in
VBA, like [mmm#] - it works with names that have spaces, like [My Name], but
not necessarily with special characters.

as for the dot vs bang: i usually use dot for object properties, like
MyForm.Tag or MyControl.ForeColor; and bang for controls, like Me!MyControl
or Me!MyCommandButton. i've read explanations of the fine points in the
differences, and they do seem to be pretty fine points, at least most of the
time. generally, i go with my standards mentioned above, and if dot doesn't
work in a particular situation, i try bang - and vice versa.

there was a good explanation of dot vs bang posted by someone just recently,
in one of these Access newsgroups. if you're interested, suggest you try
searching Google Groups, in microsoft.public.access.*, and maybe with "dot"
and "bang" keywords, and see what you come up with.

hth


mark r said:
if I change ! to . and mmm# to mmm_ the code works

why?

tina said:
i wonder how "Cancel As Integer" would get into the Arguments section of an
AfterUpdate event procedure in the first place. the AfterUpdate event does
not have a Cancel argument, either on a control or on the form. my
suggestion would be the same as Ofer's, except i might add an If statement
so that the [mmm] value is not overwritten if it already exists, as

Private Sub ssn_AfterUpdate()

If IsNull(Me!mmm) Then
Me!mmm = Me!ssn
End If

End Sub

make sure you're using the correct names of the controls that fields ssn and
mmm are bound to. (btw, do you work for Campbell's Soup? <g> )

hth


mark r said:
wait a minute...........

I took cancel as integer out of parens in Afterupdate(Cancel as Integer)
and then I got a compile error

:

On the after update event of ssn field, enter the code
Me.mmm=Me.ssn


--
In God We Trust - Everything Else We Test


:

on a form I have two fields. the first is ssn and the second we'll call mmm.
mmm is 90% populated with the same data entry as ssn but not 100%.
so
the
user is double inputing teh data into mmm 90% of the time.

As soon as the user inputs data into ssn field, I think mmm should "copy" or
"default" to whatever was typed into ssn. Then 10% of the time the user can
retype and change mmm.

How can I code "a copy" so that when the user leaves the ssn
field,
mmm
copies ssn? WHERE DO I PLACE THE CODE in CODE BUILDER?

skeleton?

ssn losefocus
let mmm = ssn

?
 

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

Top