Article ID: 109818
Article Last Modified on 1/18/2007
Option Explicit
Function OpenFormWithInput()
Dim Msg, Title, Defvalue, Answer
Msg = "Enter a Customer ID (AROUT, CACTU, THEBI, etc.)."
Title = "OPEN CUSTOMERS FORM"
Defvalue = "CACTU"
Answer = InputBox(Msg, Title, Defvalue)
If Answer <> "" Then
DoCmd.OpenForm "Customers", , , "[CustomerID]='" & Answer & "' "
Else
DoCmd.OpenForm "Customers"
End If
End Function
In Microsoft Access 1.x and 2.0:
Function OpenFormWithInput()
Dim Msg, Title, Defvalue, Answer
Msg = "Enter a Customer ID (AROUT, CACTU, THEBI, etc.)."
Title = "OPEN CUSTOMERS FORM"
Defvalue = "BOTTM"
Answer = InputBox(Msg, Title, Defvalue)
If Answer <> "" Then
DoCmd OpenForm "Customers", , , "[Customer ID]='" & Answer & "' "
Else
DoCmd OpenForm "Customers"
End If
End Function
OnClick (or OnPush in version 1.x): =OpenFormWithInput()
Keywords: kbinfo kbprogramming KB109818