나눔터  
  HOME > 나눔터 > 묻고답하기 > 액세스
액세스
액세스에 대한 질문과 답변을 올려주세요. 단, 취지에 맞지 않는 글은 운영자가 삭제합니다.
 "000 님, 도와주세요", "부탁 드립니다.", "급합니다!" 등과 같이 막연한 제목을 달지 말아주세요.
[필독] 빠르고 정확한 답변을 얻는 16가지 Tip !
[필독] 저작권법 개정에 따른 이용안내
작성자:  

 벤츠 (officelee)

추천:  0
파일:     조회:  701
제목:   vba에서의 수직선과 수평선 굵기 조절은
     
  * 답변하시는 분들께 도움이 되도록 자신의 환경을 아래 항목 옆에 기재해 주세요.

1. 액세스 버전(95,97,2000,2002):
2. 윈도우즈의 버전(win95,win98,winME,winNT,win2000,winXP):
3. CPU (486,PentiumI/II/III/IV...):
4. RAM (32,64,128,256,512MB,1G...): 

* 아래줄에 질문을 작성하세요 >> 

아래와 같은 vba문에서 수직선과 수평선 굵기 조정하는 방법을 
염체없이 여쭙고자 하오니 도와주시면 대단히 감사하겠습니다.

----------------------------------------------------------
' 개발 : 2000.11.3 김규경
'           http://www.moise.co.kr/k2kim

'팁 :
' 1) 정보를 표시할 컨트롤의 상하좌우여백 속성을 설정하면 훨씬 보기가 좋아진다.
' 2) 컨트롤에 박스를 치고자 하는 경우는
'    컨트롤의 속성에 수직선을 그릴 컨트롤과 그리지 않을 컨트롤을
'    표시해 두고 이를 바탕으로 수직선을 그려주면 된다.
' 3) 제일 아래에 빈 박스가 그려지지 않도록 본문의 높이를 조정하도록 한다.
'    만약 칸의 높이를 굳이 같지 않아도 되는 경우는
'    DrawGrid() 함수의 내용에서 수평선 그리는 조건식을 달리해서 마지막 빈칸을 나누는
'    수평선은 그리지 않도록 한다.


Option Compare Database
Option Explicit

Public g_lngScaleWidth As Long
Public g_lngScaleHeight As Long

Function GetPrintingWIdth(rptAny As Report) As Long
    ' 트윕댠위
    If g_lngScaleWidth = 0 Then
        g_lngScaleWidth = rptAny.ScaleWidth
    End If
    GetPrintingWIdth = g_lngScaleWidth
End Function

Function GetPrintingHeight(rptAny As Report) As Long
Dim intDetailHeight As Long

    ' 트윕댠위
    If g_lngScaleHeight = 0 Then
        g_lngScaleHeight = rptAny.ScaleHeight
        g_lngScaleHeight = g_lngScaleHeight - rptAny.Section(acPageHeader).Height
        g_lngScaleHeight = g_lngScaleHeight - rptAny.Section(acPageFooter).Height
        
        Debug.Print "본문출력개수:" & CSng(g_lngScaleHeight / rptAny.Section(acDetail).Height)
    End If
    
    GetPrintingHeight = g_lngScaleHeight
    
End Function


Function GetPrintingWIdthTwip(rptAny As Report) As Single
    ' 속성창에 입력할 수 있도록 트윕댠위를 cm 단위로 수정해서 보낸다.
    GetPrintingWIdthTwip = rptAny.ScaleWidth / 567

End Function

Function GetDetailWIdth(rptAny As Report) As Single
    GetDetailWIdth = rptAny.Width
End Function

Function DrawGridHeader(rptAny As Report, blnFitDetailWidth As Integer, Optional PageBorder As Boolean = True)
Dim intUpperLimit As Integer    ' 본문 위의 섹션의 높이를 제외하기 위함
Dim intLowerLimit As Integer    ' 본문아래의 섹션의 높이를 제외하기 위함
Dim intDrawWidth As Integer     ' 그려줄 수평선의 너비
Dim ctl As Control

    ' 1) 그리는데 필요한 옵션 설정
    With rptAny
        ' 수직선을 그릴 Top 좌표값
        intUpperLimit = .Section(acPageHeader).Controls("TopLeft_Label").Top '.Height
        ' 수직선을 그릴 Bottom 좌표값 및 수평선을 그릴 하위범위값
        intLowerLimit = .Section(acPageHeader).Height
        
       
        ' 그릴 수평선의 길이 '페이지 전체 폭 또는 본문의 폭
        If blnFitDetailWidth Then
            intDrawWidth = .Width  '본문의 폭
        Else
            intDrawWidth = .ScaleWidth '페이지 전체 폭
        End If
    
    End With
    
    ' 2) 헤더에 테두리 그리기
    With rptAny
        rptAny.Line ((0), intUpperLimit)-(intDrawWidth, intLowerLimit), , B
        
    End With
    
    ' 3) 헤더용 레이블 사이에 수직선 그리기 :
    For Each ctl In rptAny.Section(acPageHeader).Controls
        With ctl
            ' If Right(ctl.Name, 6) = "_Label" Then
            If ctl.Tag = "header" Then ' 헤더용 레이블의 Tag값을 "header"로 설정
                rptAny.Line (.Left, intUpperLimit)-(.Left, intLowerLimit)
            End If
            If ctl.Tag = "bg" Then
                 ctl.Width = intDrawWidth - 20
            End If
        End With
    Next
    

End Function

Function DrawGrid(rptAny As Report, blnFitDetailWidth As Integer, _
    Optional PageBorder As Boolean = True, _
    Optional VerticalLineOnly As Boolean = False, _
    Optional SkipLastLine As Boolean = False)
Dim ctlInDetail As Control
Dim intDetailHeight As Integer
Dim intUpperLimit As Integer    ' 본문 위의 섹션의 높이를 제외하기 위함
Dim intLowerLimit As Integer    ' 본문아래의 섹션의 높이를 제외하기 위함
Dim intDrawWidth As Integer     ' 그려줄 수평선의 너비
Dim intStartY As Integer
Dim blnDrawVLine As Boolean

    ' 1) 그리는데 필요한 옵션 설정
    With rptAny
        ' 수직선을 그릴 Top 좌표값
        intUpperLimit = .Section(acPageHeader).Height
        
        ' 수직선을 그릴 Bottom 좌표값 및 수평선을 그릴 하위범위값
        intLowerLimit = .ScaleHeight - .Section(acPageFooter).Height
        
        ' 그릴 수평선의 길이 '페이지 전체 폭 또는 본문의 폭
        If blnFitDetailWidth Then
            intDrawWidth = .Width  '본문의 폭
        Else
            intDrawWidth = .ScaleWidth '페이지 전체 폭
        End If
        
        ' 본문의 높이
        intDetailHeight = .Section(acDetail).Height
        
    End With
    
    ' 2) 테두리 그리기
    With rptAny
        If PageBorder Then
            ' 페이지 전체 테두리 그리기
            rptAny.Line (0, 0)-(intDrawWidth, .ScaleHeight), , B
        End If
        
        ' 본문에 대한 테두리 그리기
        rptAny.Line ((0), intUpperLimit)-(intDrawWidth, intLowerLimit), , B
        
    End With
    
    ' 3) 수직선 그리기 :
    '   선, 박스, 레이블 컨트롤이 아닌 경우 그 컨트롤의 좌측에 수직선을 그린다.
    '   UpperLimit, LowerLimit 값과을 조정하여 원하는 모습으로....
    For Each ctlInDetail In rptAny.Section(acDetail).Controls
        blnDrawVLine = Not (TypeOf ctlInDetail Is Access.Line Or _
                            TypeOf ctlInDetail Is Access.Rectangle Or _
                            TypeOf ctlInDetail Is Access.Label)
        If blnDrawVLine Then
            With ctlInDetail
                rptAny.Line (.Left, intUpperLimit)-(.Left, intLowerLimit)
            End With
        End If
    Next
    
    ' 4) 수평선 그리기
   ' If VerticalLineOnly = False Then
      '  With rptAny
       '     intStartY = intUpperLimit
            
       '     Do While intStartY <= intLowerLimit
                ' 본문너비보다 적은 경우는 마지막 - 이 선은 그리지 않는다.
      '          If SkipLastLine Then
      '              If (intStartY + intDetailHeight) > intLowerLimit Then
      '                  Exit Do
      '              End If
      '          End If
                
      '          rptAny.Line (0, intStartY)-(intDrawWidth, intStartY)
      '          intStartY = intStartY + intDetailHeight
      '      Loop
     '   End With
  '  End If
    
'   Set ctlInDetail = Nothing


End Function

 
[불량 게시물 신고]  
        
  

작성일 : 2005-05-16(12:40)
최종수정일 : 2005-05-16(12:40)
 


 ◎ 관련글

  제 목   작성자   날짜
vba에서의 수직선과 수평선 굵기 조절은 벤츠 2005-05-16
[RE]저번 보고서파일이 잘못올라가서 다시 올립니다. 초보맨 2005-05-16