You may be familiar with this problem as I posted it before, so here we go...
I have a module that provides error checking for the length of a SSN and I need a
little help in one area...
The code will check to see if the SSN is 9 digits exactly, and if not it will produce an error message, otherwise it will cipher the SSN. The error message is part of the VBA (the 'msg' in the code below).
My question is how can I get the code to work so it will still check for 9 digits (for use in a form) but also accept an empty string (when opening a report) and NOT produce the same error message?
Thanks My code is here: - Public Function CipherSS(SSN As String)
-
Dim Mask As String, Build As String, x As Integer
-
Dim Msg As String, Style As Integer, Title As String, DL As String
-
-
DL = vbNewLine & vbNewLine
-
-
If Len(SSN) <> 9 Then
-
Msg = "SSN Must Be Exactly 9 Digits!" & DL & _
-
"Check SSN '" & SSN & "' and try again . . ."
-
Style = vbInformation + vbOKOnly
-
Title = "SSN Not 9 Digits Error! . . ."
-
MsgBox Msg, Style, Title
-
CipherSS = Null
-
Else
-
Do
-
x = x + 1
-
-
If Asc(Left(SSN, 1)) < 58 Then
-
If (x Mod 2) = 0 Then
-
Mask = 64
-
Else
-
Mask = 32
-
End If
-
Else
-
If (x Mod 2) = 0 Then
-
Mask = -64
-
Else
-
Mask = -32
-
End If
-
End If
-
-
Build = Build & Chr(Asc(Mid(SSN, x, 1)) + Mask)
-
Loop Until x = 9
-
-
CipherSS = Build
-
-
End If
-
-
End Function
8 1728
Instead of:
try: - If Not IsNull(SSN) AND Len(SSN) <> 9 Then
Regards,
Scott
that didn't seem to work.
I still get the "Must be 9 digits error" coming up when I try to open the report with a "0" or empty string in the SSN field. still trying to figure this one out.
thanks
that didn't seem to work.
I still get the "Must be 9 digits error" coming up when I try to open the report with a "0" or empty string in the SSN field. still trying to figure this one out.
thanks
You must have your default value set to not accept nulls...
Try: - If SSN<>"0" AND SSN<>"" AND Len(SSN) <> 9 Then
Regards,
Scott
I'm confused! The technical aspect of getting the report to accept an invalid SSN aside, if you have your form set up so as to require that a valid SSN be entered, why would you need your report to accept a non-valid SSN? How is a non-valid SSN going to be entered into your table?
Linq ;0)>
I'm confused! The technical aspect of getting the report to accept an invalid SSN aside, if you have your form set up so as to require that a valid SSN be entered, why would you need your report to accept a non-valid SSN? How is a non-valid SSN going to be entered into your table?
Linq ;0)>
heres how it works:
1. OPTIONAL TO USER: ssn entered on form
2. ssn saved in table when record saved from form
3. on opening the report, the reports control source is a query that uses the module code previously posted to verify if the ssn is not null, but will still open the report even if there are blank (empty string) ssn's.
4. because the report is based off a query, and that query has "built-in" error checking using the module, it will still produce the error message contained in the code ("SSN Must be Exactly 9 Digits")
i want to get it so i can still open the report and NOT receive the error message for an empty string...thats all
hope that helps
thanks
My question is how can I get the code to work so it will still check for 9 digits (for use in a form) but also accept an empty string (when opening a report) and NOT produce the same error message?
I guess I read the question backward, and assumed the error was being generated whenever opening a form to enter a new SSN...
Regards,
Scott
I guess I read the question backward, and assumed the error was being generated whenever opening a form to enter a new SSN...
Regards,
Scott
no problem, but does anyone have a solution? i'm continuing to work on it but to no avail.
no problem, but does anyone have a solution? i'm continuing to work on it but to no avail.
Did you try the code I posted in post #4?
You don't have this same msgbox being called somewhere else, do you? Like in the On Open event of the report, etc...
Regards,
Scott
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Hamed |
last post by:
Hello
I have employed as a developer in a software company that its team uses
FoxPro / VB 6.0 / VC++ 6.0 as the developing tools and newly is going to
migrate to VS.NET. There is a project...
|
by: Mike Dwyer |
last post by:
I need a VB 6 app to automate a microsoft access MDB application.
Specifically, it needs to open a form in Access and read information
keyed into that form. I know this is "old school" but I'm...
|
by: Manuel Lopez |
last post by:
I have a puzzling form timer problem that I didn't experience prior to
Access 2003 (though I'm not sure access 2003 is to blame).
Here's the situation: a computer has two access 2003 databases on...
|
by: Yannick Turgeon |
last post by:
Hello,
We are in the process of examining our current main application. We have to
do some major changes and, in the process, are questionning/validating the
use of MS Access as front-end. The...
|
by: Olav.NET |
last post by:
I am a .NET/C++ developer who is supposed to do some work with Access.
I do not know much about it except for the DB part.
Questions:
*1*
I am looking for INTENSIVE books to get quickly up to...
|
by: dixie |
last post by:
I have an Access 2000 form which has been running OK for a long time.
Lately, it is playing up and doing things like causing Access to close
suddenly when the form is opened or when saving the form...
|
by: rdemyan via AccessMonster.com |
last post by:
I have a custom message form that I want to display when the user shuts down
my app. Some clean up needs to be done during shutdown and I want to display
this form and then display various...
|
by: ApexData |
last post by:
I am considering building some distributable commercial applications.
For about a year now, I have been using Access2000. This was my first
venture into object oriented database development. ...
|
by: prakashwadhwani |
last post by:
Hi !! I'm about to develop a new project for a client.
Should I go about it in Access 2003 or 2007 ? Purchasing it either
for me or for my client is not a major consideration here ... what I'd...
|
by: hyperpau |
last post by:
Before anything else, I am not a very technical expert when it comes to VBA coding.
I learned most of what I know by the excellent Access/VBA forum from bytes.com (formerly thescripts.com).
Ergo, I...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
| |