Option Compare Database
Option Explicit
Public strInpBoxRes As String
Function InpBox(strPrompt As String, _
Optional strTitle As Variant, _
Optional strDefault As Variant, _
Optional strHelp As Variant) As String
Dim F As Form_frmInpBox
DoCmd.OpenForm „frmInpBox“
On Error Resume Next
Set F = Forms(„frmInpBox“)
If Err <> 0 Then
Beep
MsgBox „InpBox: Formular »frmInpBox« nicht gefunden…“
InpBox = „“
Exit Function
End If
With F
.lblPrompt.Caption = strPrompt
If Not IsMissing(strTitle) Then
.Caption = strTitle
End If
If Not IsMissing(strDefault) Then
.lblDefault.Caption = strDefault
With .txtInput
.Text = strDefault
.SelStart = 0
.SelLength = 999
End With
Else
.lblDefault.Caption = „“
.btnUndo.Enabled = False
End If
If Not IsMissing(strHelp) Then
.lblHelp.Caption = strHelp
Else
.lblHelp.Caption = „“
.btnHelp.Enabled = False
End If
End With
While SysCmd(acSysCmdGetObjectState, acForm, „frmInpBox“) = acObjStateOpen
DoEvents
Wend
InpBox = strInpBoxRes
End Function
Sub Test()
Dim strX
strX = InpBox(„Bitte den gesuchten Ort eingeben:“, _
„Ort eingeben:“, _
„Hamburg“, _
„Dies ist ein Beispiel für einen Hilfetext…“)
End Sub