vb datagrid列头字段排序异常错误怎么处理
Private Sub DataGrid1_HeadClick(ByVal ColIndex As Integer)On Error GoTo AA
If Adodc1.RecordSource = "" Then
Exit Sub
End If
Dim strORDER As String
If InStr(UCase(Adodc1.RecordSource), UCase("DESC")) = 0 Then
strORDER = " DESC"
Else
strORDER = " ASC"
End If
If InStr(UCase(Adodc1.RecordSource), UCase("order by")) = 0 Then
Adodc1.RecordSource = Adodc1.RecordSource & " order by " & DataGrid1.Columns(ColIndex).DataField & strORDER
Else
Adodc1.RecordSource = Left(Adodc1.RecordSource, InStr(UCase(Adodc1.RecordSource), UCase("order by")) - 1) & " order by " & DataGrid1.Columns(ColIndex).DataField & strORDER
End If
Adodc1.Refresh
Exit Sub
AA:
MsgBox "错误:" + (err.Description) + Chr(10) + "服务器连接异常,请与系统管理员联系!"
End Sub
当点击datagrid某一列列头时,如果此列数据全部是空,点击此列头就有错误,怎么样处理呀 --------------------编程问答-------------------- 不喜欢dim在中间。
哪行错误? --------------------编程问答--------------------
此列全为空还排什么序,屏蔽错误不操作就行了.
将On Error GoTo AA 替换为
On Error resume next --------------------编程问答-------------------- DataGrid1.Columns(ColIndex).DataField ---> DataGrid1.Columns(ColIndex).Caption --------------------编程问答-------------------- I don't know
补充:VB , 控件