简体   繁体   中英

Need a popup window to open only the first time in a continuous form

I have a continuous form with a combobox with the control source of ProductID.

I have the following vba code:

Private Sub ProductID_AfterUpdate()
if (productID=1 or productID=2) then
docmd.openform "frminfo"
end if
End Sub

I want that popup window ("frminfo") to open ONLY the first time the condition is true. How should I modify this?

Declare a boolean public variable or TempVar or use an UNBOUND textbox and set to True when the condition is met. Include value of whichever in the If condition.

Option Compare Database
Option Explicit
Public booTest As Boolean
____________________________________________________________________

Private Sub ProductID_AfterUpdate()
If (productID=1 Or productID=2) And booTest = False Then
    DoDmd.OpenForm "frminfo"
    booTest = True
End If
End Sub

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM