Solved

Changing a fields control source based on the type on input

Posted on 2013-06-06
3
238 Views
Last Modified: 2013-06-06
Ok, so I have a SSN field.  Right now it displays correctly so that is not a problem.  But what I want the field to do is change it's control source based on whether a new record is being added our not.

Currently the control source displays like this:
="XXX-XX-"+Right([SSN],4)

This displays only the last four of a SSN

But when I add a record I want the control source to go blank, then on the after update I want the control source to display how it would normally.

Thanks
John
0
Comment
Question by:John Sheehy
  • 2
3 Comments
 
LVL 57

Accepted Solution

by:
Jim Dettman (Microsoft MVP/ EE MVE) earned 500 total points
ID: 39226098
John,

 In the forms OnCurrent event, do:

 If Me.NewRecord = True then
   Me.<myControlName>.ControlSource = "[SSN]"
Else
   Me.<myControlName>.ControlSource = "XXX-XX-"+Right([SSN],4)
 End If

Jim.
0
 

Author Comment

by:John Sheehy
ID: 39226289
Jim,

That worked.  Thank you very much.

John

PS still have the coin coming.  We had an issue with getting coins. Should be here next wednesday.
0
 

Author Closing Comment

by:John Sheehy
ID: 39226292
Great solution.  Quick and direct to the point.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
In earlier versions of Windows (XP and before), you could drag a database to the taskbar, where it would appear as a taskbar icon to open that database.  This article shows how to recreate this functionality in Windows 7 through 10.
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

808 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question