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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to fix Excel Return Null From ADO RecordsetOpen?

Status
Not open for further replies.

cvl75

Programmer
Mar 8, 2002
19
US
I have a small application that read provider numbers from
and excel worksheet but when a provider number intermix with alpha-numeric the recordset return Null and Don't know how to get around this. Any helps would be appreciated.

Thanks,
CL
 
I've gotten around this problem by using the following function which I have placed in a module.

Public Function GetString(rVar_InData As Variant) As String

Dim lStr_WorkStr As String

If Not (IsNull(rVar_InData)) Then
lStr_WorkStr = Trim(CStr(rVar_InData))
Else
lStr_WorkStr =
End If

GetString = lStr_WorkString

End Function

---

Then change your assignment statements to the following

txtText.Text = GetString(rsRecSet("ColumnName"))
Good Luck
--------------
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein


 
Cajun,
That's not what I want. The reason that record is null because the provider number contain Alpha-Numberic Value.
Not because that record does not exist.

 
What that code is doing is converting a null value in the recordset for a specific column into a valid nullstring. It has nothing to do with a record not found condition.

If Not (IsNull(rVar_InData)) Then
lStr_WorkStr = Trim(CStr(rVar_InData))
Else
lStr_WorkStr = vbNullString
End If
Good Luck
--------------
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein


 
Cajun,
I understand What it does, but that's not what I want.
when the recordset hits the providernumber that contains ALpha-numeric, It returns a value null even though that provider exist in the worksheet.

Thanks,
CL
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top