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

A couple of ways...

... = Trim(AfsugRS(j - 1))

... = AfsugRS(j - 1) & vbNullString

Or you could try an update statement...

strSQL = "UPDATE Table1 SET Field1 = " & vbNullString & " Where Field1 = " & vbNull

(or something like that as I don't remember the last time I had to do it... it could be...)

strSQL = "UPDATE Table1 SET Field1 = " & vbNullString & " Where Field1 = Null"


Good Luck

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.