Form created with following lblMessage ,MSflexgrid, cmdsearch , optName, & optNumber,
Table exits under sql
------------------------------------------------------------
1.clsADO connection
program is connecting correctly to sql via clsado.
------------------------------------------------------------
2.clssetvalue
Public m_IntCurGridSearch As Integer
Public Property Get pIntGridSearch() As Integer
pIntGridSearch = m_IntCurGridSearch
End Property
Public Property Let pIntGridSearch(ByVal intNewGridSearch As Integer)
m_IntCurGridSearch = intNewGridSearch
End Property
------------------------------------------------------------
3.module
Public oCn As Object 'Connection
Public oRs As Object 'Recordset
Public i As Integer ' MSflexgrid
' MSHFlex Grid Variables 'IcMSFlexGrid
Public iRow As Integer
Public iCol As Integer
Public Body As String
Public Header As String
Public sSQL1 As String
Public sSql2 As String
Public iRecordCount As Integer
------------------------------------------------------------
4.clsMsflexgrid
Functions are created on global basis and which can be used to various other database to be created
Public Function fSelectSQLGrid(iGrdSQLIndex) As String
Dim strsql As String
Dim strInputBox As String
Select Case iGrdSQLIndex
Case 1
strsql = "SELECT * from temptbl"
Select Case ISet.pIntGridSearch
Case 0 ' Name
strInputBox = InputBox(" Enter Full or Partial Name ....", "Enter Name")
If strInputBox <> "" Then
strsql = strsql & "WHERE name = '"
strsql = strsql & strInputBox & "'"
strsql = strsql & " or name like '"
strsql = strsql & strInputBox & "%'"
End If
Case 1 ' Number
strInputBox = InputBox(" Enter NINE (9) digit number", "Enter number")
If Len(strInputBox) <> 9 Then
MsgBox ("Please retry, Error encountered - Invalid Number:" & strInputBox), vbOKOnly, "Error - Check length of #"
End If
strsql = strsql & "WHERE number = '"
strsql = strsql & strInputBox & "'"
Case 2 ' Type
Case 3 ‘SP
End Select
fSelectSQLGrid = strsql
End Function
---------------------------------------------------------------------
Public Function fGridDataLoad(MSgrd As MSFlexGrid, sTSQL As String)
Dim X
' Open connection and recordset
Set oCn = IAdo.fncSetObjConnRpt
Set oRs = IAdo.fncSetRSOpen(IAdo.fncSetObjConnRpt, sTSQL)
' Header fields selected
' get the list of fields selected
MSgrd.Cols = oRs.Fields.Count
For i = 0 To oRs.Fields.Count - 1
Header = Header & oRs.Fields(i).Name & Chr(9)
Next i
sSQL1 = sSQL1 & Header & vbNewLine
MSgrd.Rows = 0
MSgrd.AddItem Header
iRecordCount = 0
Do While Not oRs.EOF
iRow = iRow + 1
Body = ""
For Each X In oRs.Fields
Body = Body & X.Value & Chr(9)
Next
sSQL1 = sSQL1 & Body & vbNewLine
MSgrd.AddItem Body
oRs.MoveNext
Loop
iRecordCount = oRs.RecordCount
'MSgrd.Rows = oRs.RecordCount + 10
IAdo.sADOClose oCn, oRs
End Function
5 frmDisplay
Private Sub optSearch_Click(Index As Integer)
ISet.m_IntCurGridSearch = Index
End Sub
'-----------------------------------------------------------
Private Sub cmdsearch_Click(Index As Integer)
frmRefFiles.lblMessage(0).Caption = "Please choose options to view data from PRV414"
If IGrid.fGridDataConfirm(MSFlxgrd(1), 1, frmRefFiles) = False Then Exit Sub
MousePointer = vbHourglass
MSFlxgrd(1).Clear
lblMessage(0).ForeColor = RGB(10, 50, 200)
lblMessage(0).FontBold = True
End Sub
I still need to add functions to clear grid, and format grid with header row.
Problem is when NAME option button is selected and cmdsearch clicked, input box appears. If strinputbox is null or cancelled, program is hung and does not respond at all.
If number button and cmdsearch click, and strinputbox either null or cancel, system is not hung and responds correctly.
Can someone please look into this and help would be appreciated.
If need be, please amend codes.
Thanks
spag
Table exits under sql
------------------------------------------------------------
1.clsADO connection
program is connecting correctly to sql via clsado.
------------------------------------------------------------
2.clssetvalue
Public m_IntCurGridSearch As Integer
Public Property Get pIntGridSearch() As Integer
pIntGridSearch = m_IntCurGridSearch
End Property
Public Property Let pIntGridSearch(ByVal intNewGridSearch As Integer)
m_IntCurGridSearch = intNewGridSearch
End Property
------------------------------------------------------------
3.module
Public oCn As Object 'Connection
Public oRs As Object 'Recordset
Public i As Integer ' MSflexgrid
' MSHFlex Grid Variables 'IcMSFlexGrid
Public iRow As Integer
Public iCol As Integer
Public Body As String
Public Header As String
Public sSQL1 As String
Public sSql2 As String
Public iRecordCount As Integer
------------------------------------------------------------
4.clsMsflexgrid
Functions are created on global basis and which can be used to various other database to be created
Public Function fSelectSQLGrid(iGrdSQLIndex) As String
Dim strsql As String
Dim strInputBox As String
Select Case iGrdSQLIndex
Case 1
strsql = "SELECT * from temptbl"
Select Case ISet.pIntGridSearch
Case 0 ' Name
strInputBox = InputBox(" Enter Full or Partial Name ....", "Enter Name")
If strInputBox <> "" Then
strsql = strsql & "WHERE name = '"
strsql = strsql & strInputBox & "'"
strsql = strsql & " or name like '"
strsql = strsql & strInputBox & "%'"
End If
Case 1 ' Number
strInputBox = InputBox(" Enter NINE (9) digit number", "Enter number")
If Len(strInputBox) <> 9 Then
MsgBox ("Please retry, Error encountered - Invalid Number:" & strInputBox), vbOKOnly, "Error - Check length of #"
End If
strsql = strsql & "WHERE number = '"
strsql = strsql & strInputBox & "'"
Case 2 ' Type
Case 3 ‘SP
End Select
fSelectSQLGrid = strsql
End Function
---------------------------------------------------------------------
Public Function fGridDataLoad(MSgrd As MSFlexGrid, sTSQL As String)
Dim X
' Open connection and recordset
Set oCn = IAdo.fncSetObjConnRpt
Set oRs = IAdo.fncSetRSOpen(IAdo.fncSetObjConnRpt, sTSQL)
' Header fields selected
' get the list of fields selected
MSgrd.Cols = oRs.Fields.Count
For i = 0 To oRs.Fields.Count - 1
Header = Header & oRs.Fields(i).Name & Chr(9)
Next i
sSQL1 = sSQL1 & Header & vbNewLine
MSgrd.Rows = 0
MSgrd.AddItem Header
iRecordCount = 0
Do While Not oRs.EOF
iRow = iRow + 1
Body = ""
For Each X In oRs.Fields
Body = Body & X.Value & Chr(9)
Next
sSQL1 = sSQL1 & Body & vbNewLine
MSgrd.AddItem Body
oRs.MoveNext
Loop
iRecordCount = oRs.RecordCount
'MSgrd.Rows = oRs.RecordCount + 10
IAdo.sADOClose oCn, oRs
End Function
5 frmDisplay
Private Sub optSearch_Click(Index As Integer)
ISet.m_IntCurGridSearch = Index
End Sub
'-----------------------------------------------------------
Private Sub cmdsearch_Click(Index As Integer)
frmRefFiles.lblMessage(0).Caption = "Please choose options to view data from PRV414"
If IGrid.fGridDataConfirm(MSFlxgrd(1), 1, frmRefFiles) = False Then Exit Sub
MousePointer = vbHourglass
MSFlxgrd(1).Clear
lblMessage(0).ForeColor = RGB(10, 50, 200)
lblMessage(0).FontBold = True
End Sub
I still need to add functions to clear grid, and format grid with header row.
Problem is when NAME option button is selected and cmdsearch clicked, input box appears. If strinputbox is null or cancelled, program is hung and does not respond at all.
If number button and cmdsearch click, and strinputbox either null or cancel, system is not hung and responds correctly.
Can someone please look into this and help would be appreciated.
If need be, please amend codes.
Thanks
spag