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

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

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

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.