|
|
Question : Run-Time Error 6 Overflow
|
|
I am using access 2000 connected to a sql server 2000 database. Everything works fine when I run the code on a windows 2000 workstation, but does not work on win98. I get the run-time error '6': overflow message. Here is the code:
Function FormatName(id As Long) As String Dim sql As String Dim rst As New ADODB.Recordset If IsNull(id) Then FormatName = "" Else sql = "SELECT * FROM dbo_Name WHERE NameId = " & id rst.Open sql, CurrentProject.Connection, adOpenStatic, adLockReadOnly If rst.RecordCount = 1 Then FormatName = "" FormatName = FormatName & IIf(IsNull(rst.Fields("LastName")), "", rst.Fields("LastName") & ", ") *** THIS IS THE LINE IT CRASHES ON *** FormatName = FormatName & IIf(IsNull(rst.Fields("Prefix")), "", rst.Fields("Prefix") & ", ") FormatName = FormatName & IIf(IsNull(rst.Fields("FirstName")), "", rst.Fields("FirstName") & " ") FormatName = FormatName & IIf(IsNull(rst.Fields("MiddleName")), "", rst.Fields("MiddleName") & " ") FormatName = FormatName & IIf(IsNull(rst.Fields("Suffix")), "", rst.Fields("Suffix") & " ") FormatName = FormatName & IIf(IsNull(rst.Fields("SecondaryName")), "", "(" & rst.Fields("SecondaryName") & ")") FormatName = RTrim(FormatName) FormatName = IIf(Mid(FormatName, Len(FormatName), 1) = ",", Mid(FormatName, 1, (Len(FormatName) - 1)), Mid(FormatName, 1, (Len(FormatName)))) Else FormatName = "" End If rst.Close End If End Function
thanks
|
Answer : Run-Time Error 6 Overflow
|
|
An Overflow comes when you are trying to jam information into a data type that cannot handle it. Try explicitly declaring FormatName and see if that helps.
Walt
|
|
|
|
|