If rs.BOF And rs.EOF Then
MsgBox "User tidak terdaftar", , "Info"
txt_user.SetFocus
Exit Sub
End If
jlhdata = WorksheetFunction.CountA(Sheets("db_Customer").Range("A2:A1048576"))
Select Case jlhdata
Case Is > 0
area = "A2:D" & jlhdata + 1
frm_CustomerData.lst_data.Enabled = True
Case 0
area = "A2:D2"
frm_CustomerData.lst_data.Enabled = False
End Select
With frm_CustomerData.lst_data
.ColumnCount = 4
.ColumnHeads = True
.ColumnWidths = "100;150;220;100"
.RowSource = Worksheets("db_Customer").Range(area).Address(external:=True)
End With
Select Case jlhdata
Case Is > 0
area = "A2:D" & jlhdata + 1
frm_CustomerData.lst_data.Enabled = True
Case 0
area = "A2:D2"
frm_CustomerData.lst_data.Enabled = False
End Select
With frm_CustomerData.lst_data
.ColumnCount = 4
.ColumnHeads = True
.ColumnWidths = "100;150;220;100"
.RowSource = Worksheets("db_Customer").Range(area).Address(external:=True)
End With
Call Koneksi
SqlQueryString = "SELECT * FROM SA"
Set rs = New ADODB.Recordset
rs.Open SqlQueryString, cnAccess, adOpenForwardOnly, adLockOptimistic
'Display Judul
Dim j As Integer
For j = 0 To rs.Fields.Count - 1
With Worksheets("Data2")
.Cells(1, j + 1) = rs.Fields(j).Name
.Cells(1, j + 1).Font.Bold = True
.Cells(1, j + 1).Interior.ColorIndex = 15
.Range("A2").CopyFromRecordset rs
.Columns("A:Z").AutoFit
End With
Next j
rs.Close
Set rs = Nothing
SqlQueryString = "SELECT * FROM SA"
Set rs = New ADODB.Recordset
rs.Open SqlQueryString, cnAccess, adOpenForwardOnly, adLockOptimistic
'Display Judul
Dim j As Integer
For j = 0 To rs.Fields.Count - 1
With Worksheets("Data2")
.Cells(1, j + 1) = rs.Fields(j).Name
.Cells(1, j + 1).Font.Bold = True
.Cells(1, j + 1).Interior.ColorIndex = 15
.Range("A2").CopyFromRecordset rs
.Columns("A:Z").AutoFit
End With
Next j
rs.Close
Set rs = Nothing
Langganan:
Postingan (Atom)