Error 3315 Runtime

T

TimH

Thank you in advance for any assistance:
I have a field unbound that parses a name into its constituents LastName,
FirstName and so on, when a new name is enterd Code works fine; However when
user is looking at previously enterd names and the focus is on the txtName
field I get the error 3315 this is the code now; what or how do I need to add
to the code; I'm lost;

Private Sub txtName_Exit(Cancel As Integer)


Dim intRetVal As Integer
Dim strSalutation As String
Dim strLastName As String
Dim strFirstName As String
Dim strMiddleName As String
Dim strSuffix As String


intRetVal = ParseName(strSalutation, strLastName, strFirstName, _
strMiddleName, strSuffix, txtName)

Salutation = strSalutation
LastName = strLastName
FirstName = strFirstName
MiddleName = strMiddleName
Suffix = strSuffix

Me.Refresh


End Sub
 
D

Douglas J. Steele

Error 3315 indicates that you're trying to store a zero-length string ("")
in a field that cannot hold a zero-length string.

That implies that your ParseName function is returning a zero-length string
for one (or more) of the constituent parts of the name. You could either
change the definition of the table field(s) in question so that they accept
zero-length strings (set the AllowZeroLength property to True), or you can
check for a zero-length value, and only store the values that aren`t
zero-length:

If Len(strSalutation) > 0 Then
Salutation = strSalutation
End If
If Len(strLastName) > 0 Then
LastName = strLastName
End If

etc.
 
T

TimH

I have tried a number of codes however an error is allways returning;

Again thank you for taking the time to answer in advanced:
Perhaps I am not frasing my question correctly?

In addition to the txtName (unboud) field I have a date(bound), SSN(bound)
and a subjectkey(bound); when the focus is on DAte, SSn Or subjectkey, a user
can scroll through all the list of Patients, through out this the txtName
shows nothing(blank); how do I code to have txtName populated with Patients
name as user scrolls through, and would this not eliminate the zero length
string error?
 
D

Douglas J. Steele

In the code sample you posted, you're calling the function ParseName.
Presumably ParseName is setting one (or more) of values for strSalutation,
strLastName, strFirstName and so on to a zero-length string (""), and the
fields in your table haven't been set up to be able to store zero-length
strings. Where you put your code isn't going to change that fact.
 
T

TimH

Ok Douglas J. Steele,
as I understand my function I need when a new patient is enterd and Date,
SSN, is entered the focus goes to txtName, user enters name and Function
Returns StrSalutation etc unless zero-length string(""), however how can i
code so that if previously for a set SSN there is a salutation in the
tblPatients but when GotFocus on txtName shows blank even though all srings
are in the table?

again thank you especialy for the quik responce.
timH
 
D

Douglas J. Steele

I'm sorry, but I don't understand what you're asking.

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


TimH said:
Ok Douglas J. Steele,
as I understand my function I need when a new patient is enterd and Date,
SSN, is entered the focus goes to txtName, user enters name and Function
Returns StrSalutation etc unless zero-length string(""), however how can i
code so that if previously for a set SSN there is a salutation in the
tblPatients but when GotFocus on txtName shows blank even though all
srings
are in the table?

again thank you especialy for the quik responce.
timH
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top