One Text Box Filling in Multiple Fields (1 Viewer)

Zaxxon

Registered User.
Local time
Today, 15:16
Joined
Aug 5, 2008
Messages
22
Hi, I have a form where the user enters a file number which is in the format "YY-####", YY being the year and #### being a unique number assigned to the file. For example, "08-3457" would be a file number.

In my table I have a field [File Number] that stores the whole file number, and also a field [Matter Number] that just store the last four digits. This is just something my employers wants to have two separate fields for.

I'm wondering though, to save some time on data entry, if when a user enters the file number (08-3456) in a form, the [Matter Number] is also updated (3456).

I was trying something like "=Right([File Number],4)". This works if I put it in the Control Source of the text box, but then of course it's not linked to the table. I tried it in the Default Value box, but that doesn't work either as the [File Number] field is empty when the form is first opened.

Any thoughts on how to do this or perhaps a better way. I have a date field, so perhaps the user could just enter the Matter Number and Date, then the File Number could automatically be formed using the two.
 

dkinley

Access Hack by Choice
Local time
Today, 14:16
Joined
Jul 29, 2008
Messages
2,016
Two possibilities are ...

If you file number is autonumbering on record creation you could use it on the OnCurrent() event of the form...
Code:
    If Me.NewRecord Then
      Me!txtMatterNumber = Right(Me!txtFileNumber,4)
    End If

If not, then how about using it on the AfterUpdate() event of the file number control.

Code:
Me!txtMatterNumber = Right(Me!txtFileNumber,4)

-dK
 

Zaxxon

Registered User.
Local time
Today, 15:16
Joined
Aug 5, 2008
Messages
22
Perfect, ya the AfterUpdate() one worked great. I don't use autonumbering as sometimes the file numbers repeat, so I couldn't use the first one.

Thanks!
 

Users who are viewing this thread

Top Bottom