Wrox Programmer Forums
|
Access Discussion of Microsoft Access database design and programming. See also the forums for Access ASP and Access VBA.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 4th, 2008, 07:38 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 518
Thanks: 0
Thanked 0 Times in 0 Posts
Default data entry pre-fix value

I have text field in form (Reference No)
data entries like this.

Referecne No
----------------
2.1A-101
2.1A-102
2.1A-103
2.1A-....
....

2.1A- is constant value during data entries.
How can make pre-fix 2.1A- in the form field during
data entries, no need to enter 2.1A-

user only enter last digits i.e. 101, 102, 103,.....
it save full record in table i.e.
2.1A-101,
2.1A-102
2.1A-103...
...

What properties will change in form filed ?

Thanks and regards
Mateen
 
Old February 4th, 2008, 07:48 AM
Friend of Wrox
 
Join Date: Oct 2007
Posts: 130
Thanks: 0
Thanked 3 Times in 3 Posts
Send a message via AIM to urtrivedi
Default

open table in design mode
click on field you want to change
in below pane you wil find input mask
paste following line into input mask
"21.A-"CCCCCCCCCCCCCCCCCCCCCCCCCC...

repeat C for you n-5 time where n is lenght of you field



urt

Help yourself by helping someone.
 
Old February 4th, 2008, 08:45 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 518
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks for response.

I paste your code in field property,
it only save the records last digit
it not recording, 21.A-

is should be records the pre-fix value also ?
it should records in the table like this.

2.1A-101
2.1A-102
2.1A-103
....
so on

input mast also save the pre-fix value in the table how ?

Thanks
Mateen



 
Old February 11th, 2008, 04:04 PM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

Subsequent display issues aside, you could give the user an unbound form field for them to enter 101, 102, etc. Then on the Before Insert and Before Update events of the form, add this code:

Dim sString As String

sString = "2.1A-" & Me.unboundTextFieldName

Me.ReferenceNo = sString

This will save the string the user enters, plus your additional characters when they create a new record or update an existing record. Make sure the ReferenceNo field is set to Visible = No so the user doesn't try to enter data into it.

Did this help?

mmcdonal

Look it up at: http://wrox.books24x7.com
 
Old February 15th, 2008, 08:56 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,151
Thanks: 2
Thanked 14 Times in 14 Posts
Send a message via ICQ to SerranoG Send a message via AIM to SerranoG
Default

There are other ways to deal with this.

You could set the default value of that field to "2.1A-" and then place the cursor in the position after the hyphen on the textbox's GOT FOCUS event.

You could just set the field to all numbers and place the "2.1A-" in the label in front of the text box. The user ONLY types in the numbers and never the text part. The text part just goes along for the ride in as part of the label in reports, etc.



Greg Serrano
Michigan Dept. of Environmental Quality, Air Quality Division
 
Old February 17th, 2008, 07:52 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 518
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks you very much.
it is more easy to give default value to that field to "2.1A-".
it is saving the default value with the current data entry records..

I was also try to use before insert and before update event with above code.
but it was not saving the require value.

Thanks and regards
Mateen







Similar Threads
Thread Thread Starter Forum Replies Last Post
pre checking of submitted data bond007 PHP How-To 1 October 15th, 2008 11:24 PM
Data Entry from Repeater m_t_clayton ASP.NET 2.0 Professional 0 March 20th, 2006 06:13 PM
Data entry from email SiliconFuRy PHP Databases 4 December 17th, 2004 09:40 AM
error in data entry vickyj SQL Server 2000 6 September 13th, 2004 10:02 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.