If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Message Box Question
Hello all
I am hoping that somebody will help me with a code solution to indicate that the length of a text box entry is to short. The text box is for UK post codes and they should have more than for characters... is there some way to create a messgae box that will tell the user that they need to add some more text thanking you for any advice Bob |
#2
|
|||
|
|||
Message Box Question
Hello Bob,
Put the following code in the BeforeUpdate event of the textbox: If Len(Me!NameOfTextBox) 5 Then MsgBox "You Need To Add More Some More Text",,"UK Post Codes Have More Than Four Characters" Cancel = True End If -- PC Datasheet Your Resource For Help With Access, Excel And Word Applications www.pcdatasheet.com "Bob Christie" wrote in message ... Hello all I am hoping that somebody will help me with a code solution to indicate that the length of a text box entry is to short. The text box is for UK post codes and they should have more than for characters... is there some way to create a messgae box that will tell the user that they need to add some more text thanking you for any advice Bob |
#3
|
|||
|
|||
Message Box Question
Great, this works very well - thanks very much
Is it a complicated job to add another validation into these types of code, say that you needed the first digit has to be a letter or the testbox needs a combination of both thanks a lot for the coding Bob -----Original Message----- Hello Bob, Put the following code in the BeforeUpdate event of the textbox: If Len(Me!NameOfTextBox) 5 Then MsgBox "You Need To Add More Some More Text",,"UK Post Codes Have More Than Four Characters" Cancel = True End If -- PC Datasheet Your Resource For Help With Access, Excel And Word Applications www.pcdatasheet.com "Bob Christie" wrote in message ... Hello all I am hoping that somebody will help me with a code solution to indicate that the length of a text box entry is to short. The text box is for UK post codes and they should have more than for characters... is there some way to create a messgae box that will tell the user that they need to add some more text thanking you for any advice Bob . |
#4
|
|||
|
|||
Message Box Question
if your postal code is a set length, you can use the Input Mask - either at
the table level or at the form level - to validate the characters entered. if you set it at the table level, it carries over to any new forms you create afterward, using that field; if you set it at the form level instead, it only applies to the form you set it in. as an example, U.S. postal codes are either 5 digits or 9 digits in length - the first 5 digits are always required, but the last 4 digits (usually) are not. so i set an Input Mask on that field as 00000\-9999;;_ that tells the system that the first 5 characters must be numbers and are required, then show the hyphen - , then the last 4 characters must be numbers but are not required. the Input Mask wizard will build some standard masks for you, or you can build custom masks yourself. to use the wizard: open the table or form, go to the field (control, in a form), click on the Input Mask line in Properties, and click the Build button at the right (...). recommend that you read up on input masks, whether you build your own or use the wizard. to do so, click on the Input Mask line in Properties, from the open table or form, and press F1. Access Help will open to the appropriate topic. btw, an added bonus of using an input mask is that, in a form, you can set the text box control's AutoTab property to Yes. then when the input mask is filled during data entry, the cursor will automatically move to the next object in the tab order, without the user having to hit Tab or Enter. hth "Bob Christie" wrote in message ... Great, this works very well - thanks very much Is it a complicated job to add another validation into these types of code, say that you needed the first digit has to be a letter or the testbox needs a combination of both thanks a lot for the coding Bob -----Original Message----- Hello Bob, Put the following code in the BeforeUpdate event of the textbox: If Len(Me!NameOfTextBox) 5 Then MsgBox "You Need To Add More Some More Text",,"UK Post Codes Have More Than Four Characters" Cancel = True End If -- PC Datasheet Your Resource For Help With Access, Excel And Word Applications www.pcdatasheet.com "Bob Christie" wrote in message ... Hello all I am hoping that somebody will help me with a code solution to indicate that the length of a text box entry is to short. The text box is for UK post codes and they should have more than for characters... is there some way to create a messgae box that will tell the user that they need to add some more text thanking you for any advice Bob . |
#5
|
|||
|
|||
Message Box Question
Hi Bob,
There's no simple way of validating UK postcodes. In particular, it can't be done with Access's Input Mask feature. And of course if you set your database to insist on something that looks like a UK postcode, you'll make it impossible for a user to enter an overseas address. If that doesn't matter, you can get a short way by using the VBA Like operator, e.g. Dim strPC As String StrPC = Me.NameOfTextBox.Value If (Len(strPC) 6) Or _ Not ((strPC Like "[A-Z]#") Or (strPC Like "[A-Z][A-Z]#")) Then 'can't be a valid UK postcode but for a much more powerful and flexbile approach take a look at the rgxValidate() function at http://www.mvps.org/access/modules/mdl0063.htm On Sat, 8 May 2004 10:26:44 -0700, "Bob Christie" wrote: Great, this works very well - thanks very much Is it a complicated job to add another validation into these types of code, say that you needed the first digit has to be a letter or the testbox needs a combination of both thanks a lot for the coding Bob -----Original Message----- Hello Bob, Put the following code in the BeforeUpdate event of the textbox: If Len(Me!NameOfTextBox) 5 Then MsgBox "You Need To Add More Some More Text",,"UK Post Codes Have More Than Four Characters" Cancel = True End If -- PC Datasheet Your Resource For Help With Access, Excel And Word Applications www.pcdatasheet.com "Bob Christie" wrote in message ... Hello all I am hoping that somebody will help me with a code solution to indicate that the length of a text box entry is to short. The text box is for UK post codes and they should have more than for characters... is there some way to create a messgae box that will tell the user that they need to add some more text thanking you for any advice Bob . -- John Nurick [Microsoft Access MVP] Please respond in the newgroup and not by email. |
Thread Tools | |
Display Modes | |
|
|