One-time populate two fields with "same" data

AlanM

Registered User.
Local time
Tomorrow, 03:06
Joined
Jul 11, 2004
Messages
28
I have a Company form, a typical form with fields for capturing company names, address, phone etc.

The two fields I have an issue with are:
CompanyName: a regular text field for full company name
ShortName: a regular text field for same data as above but with spaces/blanks removed (to be used as a 'quicksearch' field)

I want the ShortName field to be automatically filled when the CompanyName is entered (on a new record), but allow the ShortName field to be overwritten by the operator.

I would then like to "lock" the ShortName field, such that any subsequent amendment (accidental or otherwise) to the CompanyName will NOT automatically update the ShortName field, but there will still be occasions when legitimate changes to the ShortName field will be required.

Removing the spaces is not a problem; I have a problem determining how to control the automatic updating and subsequent updating/prevention of updating.

Suggestions please.

regards
AlanM
 
OK, thinking "out loud" here... it's not complete/valid code...
Code:
dim AutoUpdate as boolean
...

function NewRecord()
  'check if current record is new

  ...

end function

procedure CompanyName_LostFocus()
  if NewRecord and AutoUpdate then
    CreateShortName()
    AutoUpdate = false
  end if
end procedure
 
Thanks for this, you prompted me to explore "if NewRecord".

So I have now set the following:
for the Form - On Open, lock the Shortname field
for the CompanyName field - after Update, copy companyname (shortened) to Shortname
for the Shortname field - on doubleClick, unlock the field
for the Shortname field - on lostfocus, lock the field
for the Shortname field - on exit, lock the field

This combination prevents edits/changes to the Shortname field, without a double-click to unlock the field.
New records autoupdate the Shortname field.

Seems to be a workable solution.

Thanks
AlanM
 
Thanks Pat.

Which prompts me to ask, is there a handy/quick reference guide to Access events anywhere?

Regards
Alanm
 
Access help files?
(oh wait, you said handy/quick...) :p
 

Users who are viewing this thread

Back
Top Bottom