ms access - VBA global variable value disappear in other sub -
i have global variable called flag set up. can access flag every module in code, when assign value 1 in sub command97_click(), reason flag not keep value sub form_beforeupdate(cancel integer). when print flag in sub form_beforeupdate not equal 1 anymore. know silly, new vba...
bear in mind code more this, keeping basic question.
thanks in advance!
public flag integer private sub command97_click() flag = 1 end sub private sub form_beforeupdate(cancel integer) if flag = 1 docmd.runcommand accmdundo msgbox "flag = " & flag, vbinformation exit sub end if end sub
i suspect have variable scope issue. depends on flag variable defined, , there others same name elsewhere.
if public flag integer
@ top of form module, it's not global.
Comments
Post a Comment