Home > Back-end >  Need a popup window to open only the first time in a continuous form
Need a popup window to open only the first time in a continuous form

Time:09-06

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?

CodePudding user response:

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
  • Related