I am at the ending part of coding for a Library software but I am unable to move forward as I can’t figure out the way to change the color for DBGrid row. I am using MsAccess as the database. I want the color of a particular grid row to change its color to say Color. Red through coding that is. Actually this is to be executed after lapse of a particular date. There can be N number of rows, but I want only that particular row whose date has crossed the dateline turn to red(background color or show a message for that row). Also I am doing input validation check, what would be the best way for this..? I badly need technical support again. I hope I am not asking too much. Would really appreciate any kind of suggestion. Thanks.

Code for input validation. I get this error message Run time error ‘13’: Type mismatch. And even if the warning message is shown the details are already added to the data base and all text box cleared.

Data1.RecordSource = "select * from Book_Details"
Data1.Refresh
Data1.Recordset.AddNew
If Val(Text1.Text) <> "" Then   	‘Works without input validations.
    Data1.Recordset.Fields(0) = Text1.Text
        If Val(Text2.Text) <> "" Then
            Data1.Recordset.Fields(1) = Text2.Text
 	 Else
          	  MsgBox "Please enter the Book Name.", vbOKOnly, "BookName"
            End If
        Else
        MsgBox "Please enter the Acc No", vbOKOnly, "Acc No"
        End If
Data1.Recordset.Update
Data1.Recordset.Close
Text1.Text = ""
Text2.Text = ""

Hi, There is no way to color the particular row of DBGrid Control. It is very rigid.

I think the error at

If Val(Text1.Text) <> "" Then 

and 
If Val(Text2.Text) <> "" Then

because you are converting text1.Text to Numbers and Checking with Strings so the Type Mismatch
Try this one

If Trim(Text1.Text) <> "" Then 
'and 
   If Trim(Text2.Text) <> "" Then

Trim Function removes the Whitespaces

Also
use Exit Sub when the Record is not updated. This is happen in validation. That is use Exit Sub, After the MsgBox () . Because your code shows the record will be updated even the validation fails.

If Trim(Text1.Text) <> "" Then   	‘Works without input validations.
    Data1.Recordset.Fields(0) = Text1.Text
    If Trim(Text2.Text) <> "" Then
         Data1.Recordset.Fields(1) = Text2.Text
    Else
         MsgBox "Please enter the Book Name.", vbOKOnly, "BookName"
         Exit Sub   
    End If
Else
    MsgBox "Please enter the Acc No", vbOKOnly, "Acc No"
    Exit Sub
End If

Mighty thanks for the elaborate explanation given and the much needed code. Also the input validation code will really help as I was struggling with it. But I was wondering if there is any way to let the user know when the deadline is crossed, say through message box(datas which are displayed through Grid layout). And if it can be done, how?

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.