forcing data

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

hello All,

I have a text box on my form which require the MSISDN to be entered with a
set Prefix. I want to set it up so that a message box would appear if either
the Prefix is not used ot the MSISDN is less that the required length, how do
i do this.
prefix:27
length:11
 
Nero

Are you saying that before you update the value in that control, you want to
check to ensure that the left-most characters match something you already
know?

One approach would be to use the BeforeUpdate event of that control, and use
the Left() function to inspect what's been entered.

An alternative, if the "prefix" is something already known, would be to use
a combo box to let the user select a value, rather than have to enter it.
 
In the Got Focus event of the control following the text box or in an
invisible control that is the next control in the tab order:

If Left(Me.MyTextBox,2) <> "27" Then
MsgBox "Wrong Prefix"... blah, blah
Me.MyTextBox.SetFocus
ElseIf Len(Me.MyTextBox) < 13 Then
MsgBox "Not Minimum Length"....Blah, Blan
Me.MyTextBox.SetFocus
End If

Notice I checked the length for 13. I am assuming you need 11 + the prefix.
If the length including the prefix should be 11, then change the 13 to 11.
 
Firstly, my apologies for postong the same message over, i got an error and
assumed that the message didn't save.
Second, Klatuu....
your code works fine, thank you. just one problem tho.....
if i enter the MISISDN without the prefix, it populates the first message
"ADD Prefix 27", when i click OK, it filters the record for a Similar MSISDN.
and ignores the second message "invalid length"

This is what i have...
Private Sub Command23_Click()
If Left(Me.MSISDNHEAD, 2) <> "27" Then
MsgBox "Please enter MSISDN as 27*****", vbCritical + vbOKOnly, "1065
Live"
Me.MSISDNHEAD.SetFocus
ElseIf Len(Me.MSISDNHEAD) < 13 Then
MsgBox "MSISDN should be 11 digits, please check and re-enter",
vbCritical = vbOKOnly, "Invalid Entry"
Me.MSISDNHEAD.SetFocus
ElseIf Me.DupUT = 0 Then
If DCount("[Date]", "UnresolvedQueries",
"[MSISDN]=Forms![LOgger1]![MSISDNHEAD]") <> 0 Then
MsgBox "There is one or more open queries for this MSISDN. These will be
displayed now. If you want to open another event for this MSISDN click GO
again.", vbCritical, "1065"
Me.DupUT = 1
DoCmd.OpenForm "Query"
Forms![Query]![TXTSearch] = Me.MSISDNHEAD
Forms![Query].RecordSource = "LogFilterMSISDN"
Exit Sub
End If
 
Back
Top