Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Database Design / August 2005

Tip: Looking for answers? Try searching our database.

lose focus? copy

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
mark r - 19 Aug 2005 13:57 GMT
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

?
Ofer - 19 Aug 2005 14:11 GMT
On the after update event of ssn field, enter the code
Me.mmm=Me.ssn

Signature

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
[quoted text clipped - 13 lines]
>
> ?
mark r - 20 Aug 2005 00:11 GMT
I did not trust........I tested........I got an error....help please:

The expression After Update you entered as the event property setting
produced the following error:  procedure declaration doe snot match
description of event or procedure having the same name

> On the after update event of ssn field, enter the code
> Me.mmm=Me.ssn
[quoted text clipped - 16 lines]
> >
> > ?
mark r - 20 Aug 2005 00:16 GMT
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
[quoted text clipped - 16 lines]
> >
> > ?
tina - 20 Aug 2005 02:42 GMT
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

> wait a minute...........
>
[quoted text clipped - 21 lines]
> > >
> > > ?
mark r - 20 Aug 2005 03:30 GMT
the mmm field is actually MCR#

you suggested Me! instead of Me.

if I try Me!MCR#

I get a message:   cannot find field MCR

is the # in the fieldname a problem?

> 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
[quoted text clipped - 45 lines]
> > > >
> > > > ?
mark r - 20 Aug 2005 08:34 GMT
if I change ! to .   and   mmm# to mmm_ the code works

why?

> 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
[quoted text clipped - 45 lines]
> > > >
> > > > ?
tina - 20 Aug 2005 10:45 GMT
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

> if I change ! to .   and   mmm# to mmm_ the code works
>
[quoted text clipped - 49 lines]
> > > > >
> > > > > ?
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.