AccessVBA 標準モジュール⑤フォーム操作

Option Compare Database

‘/**********************************************************
‘/*
‘/*      フォーム操作
‘/*
‘/**********************************************************
‘////////////////////////////////////////////メインメニューを開く
Sub OpenMain()

On Error GoTo Err_Main

‘メインメニューを開く
Dim stDocName As String
stDocName = “fmメインメニュー”
Application.Echo False ‘画面の描画を止める
DoCmd.OpenForm stDocName, , , acFormPropertySettings, , acWindowNormal
Application.Echo True ‘画面の描画を行う
Exit_Main:
Exit Sub

Err_Main:
MsgBox Err.Description
Resume Exit_Main
End Sub
‘////////////////////////////////////////////フォームを開く(追加・編集可能)
Sub OpenForm(FormName)

On Error GoTo Err_OpenForm

‘フォームを開く
Dim stDocName As String
stDocName = FormName
Application.Echo False ‘画面の描画を止める
DoCmd.OpenForm stDocName, , , acFormEdit, , acWindowNormal
Application.Echo True ‘画面の描画を行う
Exit_OpenForm:
Exit Sub

Err_OpenForm:
MsgBox Err.Description
Resume Exit_OpenForm
End Sub

‘////////////////////////////////////////////メインメニューを閉じる
Sub CloseMain()

On Error GoTo Err_CloseMain

‘メインメニューを閉じる
Dim stDocName As String
stDocName = “fmメインメニュー”
Application.Echo False ‘画面の描画を止める
DoCmd.Close acForm, stDocName, acSavePrompt
Application.Echo True ‘画面の描画を行う
Exit_CloseMain:
Exit Sub

Err_CloseMain:
MsgBox Err.Description
Resume Exit_CloseMain
End Sub

‘////////////////////////////////////////////フォームを閉じる
Sub CloseForm(FormName)

On Error GoTo Err_CloseForm

‘フォームを閉じる
Dim stDocName As String
stDocName = FormName
Application.Echo False ‘画面の描画を止める
DoCmd.Close acForm, stDocName, acSavePrompt
Application.Echo True ‘画面の描画を行う
Exit_CloseForm:
Exit Sub

Err_CloseForm:
MsgBox Err.Description
Resume Exit_CloseForm
End Sub

About

You may also like...

Your email will not be published. Name and Email fields are required