|
■No30064 (はつね さん) に返信
丁寧にありがとうございます。
一応、先ほど書いたあとの続きも記入しておきます。
ss = " SELECT distinct 事業所略称 FROM TBL_職制 where 事業所コード > '000' order by 事業所略称 "
rs.Open ss, dbman.cn(DB00), adOpenKeyset, adLockReadOnly
Cmbjiname.AddItem ""
If Not rs.BOF And Not rs.EOF Then
For i = 0 To rs.RecordCount - 1
Cmbjiname.AddItem rs(0)
rs.MoveNext
Next i
Cmbjiname.ListIndex = 0
End If
rs.Close
Set rs = Nothing
formloadflag = False
End Sub
Sub set_grid_data()
Dim ss1 As String
Dim ss2 As String
Dim s1 As String
Dim i As Integer
Dim j As Integer
Dim Gdata1 As String
Dim k4 As String
Dim k5 As String
ClearGrid Grid1
Cmdprt.Enabled = False
If formloadflag = True Then Exit Sub
If KeyText = "" Then
SetGridDataNOTHING Grid1, "上記で検索条件を入力又は選択してください。"
Frame2.Caption = "検索結果"
Exit Sub
End If
ss1 = "SELECT COUNT(*) FROM TBL_職制 where 事業所コード>'000'"
ss2 = "SELECT 受注元コード AS 受注元c,事業所コード AS 事業所c,部コード AS 部c,事業所略称,部略称,課略称,"
ss2 = ss2 & "事業所名称, 課名称 FROM TBL_職制 where 事業所コード>'000'"
If Text1(0).Text <> "" Then s1 = s1 & " and 受注元コード like '" & StrConv(Text1(0).Text, vbUpperCase) & "%'"
If Cmbjic.Text <> "" Then s1 = s1 & " and 事業所コード = '" & Cmbjic.Text & "'"
If Text1(1).Text <> "" Then s1 = s1 & " and 部コード like '" & StrConv(Text1(1).Text, vbUpperCase) & "%'"
If Cmbjiname.Text <> "" Then s1 = s1 & " and 事業所略称 = '" & Cmbjiname.Text & "'"
'If Text1(2).Text <> "" Then s1 = s1 & " and 部略称 like '%" & StrConv(Text1(2).Text, vbUpperCase + vbWide) & "%'"
'If Text1(3).Text <> "" Then s1 = s1 & " and 課略称 like '%" & StrConv(Text1(3).Text, vbUpperCase + vbWide) & "%'"
k4 = Text1(2).Text
k5 = Text1(3).Text
If k4 <> "" Then
Select Case CmbSelLike(0)
Case "で始まる"
s1 = s1 & " and 部略称 like '" & k4 & "%' collate Japanese_CI_AI "
Case "を含む"
s1 = s1 & " and 部略称 like '%" & k4 & "%' collate Japanese_CI_AI "
Case "で終わる"
s1 = s1 & " and 部略称 like '%" & k4 & "' collate Japanese_CI_AI "
End Select
End If
If k5 <> "" Then
Select Case CmbSelLike(1)
Case "で始まる"
s1 = s1 & " and 課略称 like '" & k5 & "%' collate Japanese_CI_AI "
Case "を含む"
s1 = s1 & " and 課略称 like '%" & k5 & "%' collate Japanese_CI_AI "
Case "で終わる"
s1 = s1 & " and 課略称 like '%" & k5 & "' collate Japanese_CI_AI "
End Select
End If
rs.Open ss1 & s1, dbman.cn(DB00), adOpenKeyset, adLockReadOnly
If Not rs.BOF And Not rs.EOF Then
Frame2.Caption = "検索結果 (対象:" & rs(0) & " Record)"
End If
rs.Close
Set rs = Nothing
ss2 = ss2 & s1 & " ORDER BY 事SEQ, 部SEQ, 課SEQ "
rs.Open ss2, dbman.cn(DB00), adOpenKeyset, adLockReadOnly
If Not rs.BOF And Not rs.EOF Then
With Grid1
.Font.Size = 9
.Redraw = False
.Cols = rs.Fields.Count + 1
For j = 0 To rs.Fields.Count - 1
.Row = 0
.Col = j
.FixedAlignment(j) = 4
Select Case j
Case 0, 1
.ColAlignment(j) = 4
.ColWidth(j) = 800
Case 2
.ColAlignment(j) = 4
.ColWidth(j) = 520
Case 3
.ColWidth(j) = 1500
Case 4, 5
.ColWidth(j) = 2000
Case 6
.ColWidth(j) = 3300
Case 7
.ColWidth(j) = 4160
Case Else
.ColWidth(j) = 1200
End Select
.Text = rs.Fields(j).Name
.Row = 1
.Col = j
'Grid1.ColAlignment(j) = 4
Next j
.ColWidth(rs.Fields.Count) = 0
For i = 0 To rs.RecordCount - 1
Gdata1 = ""
For j = 0 To rs.Fields.Count - 1
Gdata1 = Gdata1 & Trim(rs(j)) & Chr(9)
Next j
.AddItem Gdata1
rs.MoveNext
Next i
.RemoveItem 1
End With
Cmdprt.Enabled = True
Else
SetGridDataNOTHING Grid1, "該当データはございませんでした。検索条件を見直してください。"
End If
rs.Close
Set rs = Nothing
Grid1.Redraw = True
End Sub
Private Function KeyText() As String
KeyText = ""
ss = ""
For i = 0 To 3
ss = ss & Trim(Text1(i))
Next i
ss = ss & Cmbjic.Text
ss = ss & Cmbjiname.Text
KeyText = ss
End Function
Private Sub Form_Resize()
With frmJcsD010
If .Width > 10000 And .Height > 8000 Then
Frame1.Width = .Width - 200
Frame2.Width = .Width - 200
Frame2.Height = .Height - 2700
Grid1.Width = .Width - 310
Grid1.Height = Frame2.Height - 350
Cmdend.Top = Frame2.Top + Frame2.Height + 200
Cmdend.Left = .Width - 1700
set_grid_data
End If
End With
End Sub
'Form1の表示
Private Sub Grid1_DblClick()
Form1.Show
End Sub
Private Sub Grid1_KeyPress(KeyAscii As Integer)
SelectionRow Grid1
End Sub
Private Sub Grid1_RowColChange()
If printproc = True Then Exit Sub
SelectionRow Grid1
End Sub
Private Sub mnuFilePrint_Click()
DirectPrintForm Me, printpic
End Sub
Private Sub mnuHelpAbout_Click()
frmJcsVer.Show 1
End Sub
Private Sub mnuiken_Click()
epFirstForm = "frmJcsD010"
ep = JoinExeParam
WShell op.PathEXE + "JCSWPRG.exe " & ep & "U", 0
End Sub
Private Sub Text1_DblClick(Index As Integer)
Text1(Index).Text = ""
set_grid_data
End Sub
Private Sub Text1_KeyUp(Index As Integer, KeyCode As Integer, Shift As Integer)
set_grid_data
End Sub
|