0

Goodday All.
I have imported data from an MS excel spreadsheet into MS Access. All goes well unit I try to populate a MSFlexgrid with an open recordset. In my code it shows me that each and every field is found except when it gets to empty field it see's the field having a NULL value and the code stops.
Below is the code where it fails

For j = 1 To AfsugRS.Fields.Count 'this loop is for Columns
argFlexGrid.TextMatrix(i, j) = AfsugRS(j - 1) 'This is where I get an error Next

argFlexGrid.TextMatrix(i, 0) = i 'i holds the S.No.
AfsugRS.MoveNext
Next

Can Anyone advise me as to how to get around this while still using the FOR statement.

Regards
Craig Allan

2
Contributors
3
Replies
4
Views
7 Years
Discussion Span
Last Post by craigallansmith
0

Hi,

argFlexGrid.TextMatrix(i, j) = AfsugRS(j - 1)

Goodday All.
I have imported data from an MS excel spreadsheet into MS Access. All goes well unit I try to populate a MSFlexgrid with an open recordset. In my code it shows me that each and every field is found except when it gets to empty field it see's the field having a NULL value and the code stops.
Below is the code where it fails

For j = 1 To AfsugRS.Fields.Count 'this loop is for Columns
argFlexGrid.TextMatrix(i, j) = AfsugRS(j - 1) 'This is where I get an error Next

argFlexGrid.TextMatrix(i, 0) = i 'i holds the S.No.
AfsugRS.MoveNext
Next

Can Anyone advise me as to how to get around this while still using the FOR statement.

Regards
Craig Allan

0

Hi,
Try the below code to avoid the error

argFlexGrid.TextMatrix(i, j) = IIf(ISNULL(AfsugRS(j - 1) ),"",AfsugRS(j - 1) )

IIF - If only If -
if ISNULL(AfsugRS(j - 1) ) = true then "" else
ISNULL(AfsugRS(j - 1) )

Have a nice day
Shailaja :)

Goodday All.
I have imported data from an MS excel spreadsheet into MS Access. All goes well unit I try to populate a MSFlexgrid with an open recordset. In my code it shows me that each and every field is found except when it gets to empty field it see's the field having a NULL value and the code stops.
Below is the code where it fails

For j = 1 To AfsugRS.Fields.Count 'this loop is for Columns
argFlexGrid.TextMatrix(i, j) = AfsugRS(j - 1) 'This is where I get an error Next

argFlexGrid.TextMatrix(i, 0) = i 'i holds the S.No.
AfsugRS.MoveNext
Next

Can Anyone advise me as to how to get around this while still using the FOR statement.

Regards
Craig Allan

0

Hi Shailaja.
You have solved it for me.Thanks and because I am new to this forum I don't know how to congratulate you or sign this thread off.
I will try but thanks and best regards
Craig Allan

This article has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.