PC Review


Reply
Thread Tools Rate Thread

Check for format in form field

 
 
Nigel
Guest
Posts: n/a
 
      28th Apr 2008
I have a form that a user will fill out and then update a spreadsheet, one of
the fields is for Date of Birth, I would like to be able to force the field
to only accept the data in a certain way

dd-mm-yyyy or to force the field to be a date field

is there any way to accomplish this

thanks
 
Reply With Quote
 
 
 
 
Otto Moehrbach
Guest
Posts: n/a
 
      28th Apr 2008
Place this macro in the sheet module of your sheet. To access that module,
right-click on the sheet tab and select View Code. Paste this macro into
that module. "X" out of the module to return to your sheet. As written,
this macro will react to any entry in Column J. Change that as needed.
This macro doesn't check for date format, just if it's a date or not. If it
is, the macro will format the cell as you wanted. HTH Otto
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Count > 1 Then Exit Sub
If IsEmpty(Target.Value) Then Exit Sub
If Not Intersect(Target, Columns("J:J")) Is Nothing Then
Application.EnableEvents = False
If IsDate(Target.Value) Then
Target.NumberFormat = "[$-409]d-mmm-yyyy;@"
Else
MsgBox "The entry is not a valid date.", 16, "Invalid
Entry"
Target.ClearContents
End If
Application.EnableEvents = True
End If
End Sub
"Nigel" <(E-Mail Removed)> wrote in message
news:F84A0AEC-09C1-42FE-A267-(E-Mail Removed)...
>I have a form that a user will fill out and then update a spreadsheet, one
>of
> the fields is for Date of Birth, I would like to be able to force the
> field
> to only accept the data in a certain way
>
> dd-mm-yyyy or to force the field to be a date field
>
> is there any way to accomplish this
>
> thanks



 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Can a check box form field be displayed as a check mark? =?Utf-8?B?dHJhaW5lcjA3?= Microsoft Word Document Management 2 22nd Nov 2006 08:42 PM
format of Form field that allows data to be copied without format =?Utf-8?B?S2VuIEdlaGxl?= Microsoft Access Forms 6 27th Oct 2006 05:59 PM
Can I change the check style for the check box form field in '03? =?Utf-8?B?TWVyY3VyeQ==?= Microsoft Word Document Management 1 15th Aug 2006 11:29 PM
How do I format a report field to count yes/no check box in Acces. =?Utf-8?B?RnJlZGE=?= Microsoft Access Reports 2 4th Apr 2005 10:38 PM
Putting an actual check mark in a check box form field. =?Utf-8?B?TWFyZ290?= Microsoft Word Document Management 2 21st Feb 2005 09:59 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:26 AM.