Run-time error '2427 Error Message - Help!!!!!!!!

G

Guest

I am relatively new to VBA, but can manage to work through some basic issues.
However, I am receiving the following error message when I click on the
command button of a form:

Run-time error '2427
You entered an expression that has no value

When I run degug, the following code appears:

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
Dim ssn As String
If Len([SS#].Value) = 9 Then <-This is the line that debug highlightes in
yellow
ssn=[SS#].Value

End If
If Len([SS#].Value) = 8 Then
ssn = "0" & [SS#].Value
End If
If Len([SS#].Value) = 7 Then
ssn = "00" & [SS#].Value
End If
HoldSSN.Value=ssn
End Sub

I did not create this application, but am confused at how best to resolve
this problem. Any help would be greatly appreciated.
 
D

Douglas J. Steele

Well, you don't really need that checking.

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
Me.HoldSSN = Right("000000000" & Me.[SS#], 9)
End Sub

This assumes that SS# and HoldSSN are the names of text boxes on your form.
If they're something else, please provide more details.
 
G

Guest

Doug,
I will modify the code as you suggested and let you know if it is
successful. Regardless, I do appreciate your insight and quick response.

Douglas J. Steele said:
Well, you don't really need that checking.

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
Me.HoldSSN = Right("000000000" & Me.[SS#], 9)
End Sub

This assumes that SS# and HoldSSN are the names of text boxes on your form.
If they're something else, please provide more details.

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


Mohican said:
I am relatively new to VBA, but can manage to work through some basic
issues.
However, I am receiving the following error message when I click on the
command button of a form:

Run-time error '2427
You entered an expression that has no value

When I run degug, the following code appears:

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
Dim ssn As String
If Len([SS#].Value) = 9 Then <-This is the line that debug highlightes
in
yellow
ssn=[SS#].Value

End If
If Len([SS#].Value) = 8 Then
ssn = "0" & [SS#].Value
End If
If Len([SS#].Value) = 7 Then
ssn = "00" & [SS#].Value
End If
HoldSSN.Value=ssn
End Sub

I did not create this application, but am confused at how best to resolve
this problem. Any help would be greatly appreciated.
 
G

Guest

Doug,
I replaced the code per your suggestion, but still receive the same run-time
error message as before. Incidentally, SS# is a field, I don't know if this
makes any difference.

Thanks,
Mohican

Douglas J. Steele said:
Well, you don't really need that checking.

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
Me.HoldSSN = Right("000000000" & Me.[SS#], 9)
End Sub

This assumes that SS# and HoldSSN are the names of text boxes on your form.
If they're something else, please provide more details.

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


Mohican said:
I am relatively new to VBA, but can manage to work through some basic
issues.
However, I am receiving the following error message when I click on the
command button of a form:

Run-time error '2427
You entered an expression that has no value

When I run degug, the following code appears:

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
Dim ssn As String
If Len([SS#].Value) = 9 Then <-This is the line that debug highlightes
in
yellow
ssn=[SS#].Value

End If
If Len([SS#].Value) = 8 Then
ssn = "0" & [SS#].Value
End If
If Len([SS#].Value) = 7 Then
ssn = "00" & [SS#].Value
End If
HoldSSN.Value=ssn
End Sub

I did not create this application, but am confused at how best to resolve
this problem. Any help would be greatly appreciated.
 
D

Douglas J. Steele

Can you rename the field so that it doesn't have the special character in
it's name? (although putting the square brackets around it should keep that
from being a problem).

Am I correct in assuming that all you're trying to do is set a 9 character
SSN in a control named HoldSSN? Try simply setting the Control Source for
HoldSSN to =Right("000000000" & Me.[SS#], 9) (including the equal sign).

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Mohican said:
Doug,
I replaced the code per your suggestion, but still receive the same
run-time
error message as before. Incidentally, SS# is a field, I don't know if
this
makes any difference.

Thanks,
Mohican

Douglas J. Steele said:
Well, you don't really need that checking.

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
Me.HoldSSN = Right("000000000" & Me.[SS#], 9)
End Sub

This assumes that SS# and HoldSSN are the names of text boxes on your
form.
If they're something else, please provide more details.

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


Mohican said:
I am relatively new to VBA, but can manage to work through some basic
issues.
However, I am receiving the following error message when I click on the
command button of a form:

Run-time error '2427
You entered an expression that has no value

When I run degug, the following code appears:

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
Dim ssn As String
If Len([SS#].Value) = 9 Then <-This is the line that debug
highlightes
in
yellow
ssn=[SS#].Value

End If
If Len([SS#].Value) = 8 Then
ssn = "0" & [SS#].Value
End If
If Len([SS#].Value) = 7 Then
ssn = "00" & [SS#].Value
End If
HoldSSN.Value=ssn
End Sub

I did not create this application, but am confused at how best to
resolve
this problem. Any help would be greatly appreciated.
 

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