LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 24
Default run time error 13 "type mis-match"

The code below adds the next seqential number to a text box on a form.

Everything works fine until I get to the following line, after
execution of the line of code I get the "type mis-match error":-
NextSeqNumber = "MIR-" & strNum

If I remove the "MIR-" & and simple use the following, it works fine
NextSeqNumber = strNum

I checked the user form to make sure that the text box is actually a
text box and it is.

Anyone have an idea what's causing the error.

Thanks
burl_rfc

Private Sub Userform_Initialize()

frmIncidentReport.txtIncidentNo.Value = NextSeqNumber

End Sub

Public Function NextSeqNumber(Optional sFileName As String, Optional
nSeqNumber = -1) As Long
Const sDefault_Path As String = "c:\documents and settings\my
documents"
Const sDefault_fName As String = "defaultseq.txt"
Dim nFileNumber As Long

nFileNumber = FreeFile
If sFileName = "" Then sFileName = sDefault_fName
If InStr(sFileName, Application.PathSeparator) = 0 Then _
sFileName = sDefault_Path & Application.PathSeparator &
sFileName
If nSeqNumber = -1& Then
If Dir(sFileName) < "" Then
Open sFileName For Input As nFileNumber
Input #nFileNumber, nSeqNumber
nSeqNumber = nSeqNumber + 1&
Close nFileNumber
Else
nSeqNumber = 1&
End If
End If
On Error GoTo PathError
Open sFileName For Output As nFileNumber
On Error GoTo 0
Print #nFileNumber, nSeqNumber
num = nSeqNumber
If num < 10 Then
strNum = "000" & CStr(num)
ElseIf num < 100 Then
strNum = "00" & CStr(num)
ElseIf num < 1000 And num 99 Then
strNum = "0" & CStr(num)
End If

Close nFileNumber
NextSeqNumber = "MIR-" & strNum
Exit Function

PathError:
NextSeqNumber = -1&

End Function

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Run Time Error "13" Type Mismatch ExcelMonkey Excel Programming 4 July 17th 06 10:19 AM
Reasons for "Run-time error '13':Type mismatch"? BagaAzul Excel Programming 2 March 20th 06 11:08 AM
Error Handling to mitigate "Run Time Erorr 13 Type Mismatch" ExcelMonkey Excel Programming 3 October 16th 05 01:56 PM
Run-time Error "13" - File Type Mismatch brentm Excel Programming 1 February 10th 05 05:09 PM
Help with Run-time error: "Type Mismatch" Metin Excel Programming 2 January 26th 05 02:11 PM


All times are GMT +1. The time now is 10:04 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"