Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Label Not Defined 2

Status
Not open for further replies.

robojeff

Technical User
Dec 5, 2008
220
US
I am receiving the following error message; "Label Not Defined" on a drop down list Lost Focus event that was not happening before.

Something has changed but not sure what it is...

Any suggestions on how to correct this?

thanks!

Code:
Private Sub pnumb_LostFocus()
Dim x As Integer
Dim y As Integer
Dim HIBC As String
Dim partnum As String
Dim totals As Integer
Dim slen As Integer
Dim digit As String
Dim HIBCvals(43) As String
Dim remaindr As Integer
Dim pn_nodash As String
Dim varX As Variant


HIBCvals(0) = "0"
HIBCvals(1) = "1"
HIBCvals(2) = "2"
HIBCvals(3) = "3"
HIBCvals(4) = "4"
HIBCvals(5) = "5"
HIBCvals(6) = "6"
HIBCvals(7) = "7"
HIBCvals(8) = "8"
HIBCvals(9) = "9"
HIBCvals(10) = "A"
HIBCvals(11) = "B"
HIBCvals(12) = "C"
HIBCvals(13) = "D"
HIBCvals(14) = "E"
HIBCvals(15) = "F"
HIBCvals(16) = "G"
HIBCvals(17) = "H"
HIBCvals(18) = "I"
HIBCvals(19) = "J"
HIBCvals(20) = "K"
HIBCvals(21) = "L"
HIBCvals(22) = "M"
HIBCvals(23) = "N"
HIBCvals(24) = "O"
HIBCvals(25) = "P"
HIBCvals(26) = "Q"
HIBCvals(27) = "R"
HIBCvals(28) = "S"
HIBCvals(29) = "T"
HIBCvals(30) = "U"
HIBCvals(31) = "V"
HIBCvals(32) = "W"
HIBCvals(33) = "X"
HIBCvals(34) = "Y"
HIBCvals(35) = "Z"
HIBCvals(36) = "-"
HIBCvals(37) = "."
HIBCvals(38) = " "
HIBCvals(39) = "$"
HIBCvals(40) = "/"
HIBCvals(41) = "+"
HIBCvals(42) = "%"

If (pnumb = NUL) Then GoTo hibcnope
If (pnumb = "") Then GoTo hibcnope
pn_nodash = Replace(pnumb, "-", "")
 
 Me.nodash = pn_nodash

totals = 88                     ' 88 = +m25822
slen = Len(pn_nodash)
For x = 1 To slen Step 1
    digit = Mid(pn_nodash, x, 1)
    For y = 0 To 42 Step 1
       If HIBCvals(y) = digit Then
            totals = totals + y
            y = 42
       End If
    Next y
Next x

remaindr = totals Mod 43
digit = HIBCvals(remaindr)


HIBC = "+M25855" & pn_nodash & "0" & digit
Me.HIBC = HIBC

' Add code here to add the record if it does not already exist
'Set ctl = Me!pnumb
'ctl.RowSource = ctl.RowSource & ";" & Me.pn_nodash & ";" & Me.HIBC
DoCmd.SetWarnings False     ' squelch all update table qry messages

strQuery = "Update_lbl_print_qry"
DoCmd.OpenQuery strQuery, acViewNormal, acReadOnly  'create tblCount

DoCmd.SetWarnings True     ' enable all update table qry messages
End Sub
 
You have two goto statements with the paramater hibcnope, but this label isn't defined anywhere. Simply define the label "hibcnope:" somewhere below those goto statements, preferably at the end of your procedure.
 
Thanks Chunter-

I must have missed that...

I placed a label but now get the following error
(on the pn_nodash= line) which I am surprised
about as I thought testing for the NULL or the ""
would not allow this to error out:

If (pnumb = NUL) Then GoTo hibcnope
If (pnumb = "") Then GoTo hibcnope
pn_nodash = Replace(pnumb, "-", "")
 
What is the error message that you're getting? Also, what is NUL? Is that a variable that you defined, or did you mean to have NULL?
 
I changed it to Null and I was getting an "invalid use of Null" error
 
Give "IsNull(pnumb)" a try, instead of pnumb = NULL. Also, amke sure that you have Option Explicit declared at the top of your code so that we don't accidently start working with any undefined variables - this might compile fine but can lead to problems during runtime.
 
Replace this:
If (pnumb = NUL) Then GoTo hibcnope
If (pnumb = "") Then GoTo hibcnope
with this:
If Trim(pnumb & "") = "" Then Exit Sub

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top