K
Ken K
Hi all
Every other time I try to return a tag ("Me.Tag") from a form, the tag is
empty, and the form's IsLoaded property remains true, even though it's been
closed using DoCmd.Close. I must be doing something wrong but can't see what
it is. I've tested this in a brand new database (platform is Access2K on
Win2K):
I create a form named "Form1" with one command button "Command0" and one
module "Module1". Form1's modal property is Yes, popup is No. The entire
code in the project is below.
Can anyone help me figure out why the form's tag is being returned blank and
the form's IsLoaded property stays true every *other* time? Should I
reinstall Access (the build is "9.0.6926 SP3")?
Many thanks...
<<in Module1>>
Option Explicit
Option Compare Database
Sub x()
Dim x As String
Dim f As Form
Set f = Form_Form1
DoCmd.OpenForm f.Name, , , , , acDialog
x = f.Tag
'every FIRST time f.tag = ""
'every SECOND time f.tag = "mytag"
DoCmd.Close acForm, f.Name
If CurrentProject.AllForms("Form1").IsLoaded Then
'this code firest every FIRST time
'every SECOND time Isloaded is false
'and this code skipped
Debug.Print "is loaded"
End If
Set f = Nothing
End Sub
<<in Form1>>
Option Explicit
Option Compare Database
Private Sub Command0_Click()
On Error GoTo Err_Command0_Click
Me.Tag = "mytag"
Me.Visible = False
Exit_Command0_Click:
Exit Sub
Err_Command0_Click:
MsgBox Err.Description
Resume Exit_Command0_Click
End Sub
Every other time I try to return a tag ("Me.Tag") from a form, the tag is
empty, and the form's IsLoaded property remains true, even though it's been
closed using DoCmd.Close. I must be doing something wrong but can't see what
it is. I've tested this in a brand new database (platform is Access2K on
Win2K):
I create a form named "Form1" with one command button "Command0" and one
module "Module1". Form1's modal property is Yes, popup is No. The entire
code in the project is below.
Can anyone help me figure out why the form's tag is being returned blank and
the form's IsLoaded property stays true every *other* time? Should I
reinstall Access (the build is "9.0.6926 SP3")?
Many thanks...
<<in Module1>>
Option Explicit
Option Compare Database
Sub x()
Dim x As String
Dim f As Form
Set f = Form_Form1
DoCmd.OpenForm f.Name, , , , , acDialog
x = f.Tag
'every FIRST time f.tag = ""
'every SECOND time f.tag = "mytag"
DoCmd.Close acForm, f.Name
If CurrentProject.AllForms("Form1").IsLoaded Then
'this code firest every FIRST time
'every SECOND time Isloaded is false
'and this code skipped
Debug.Print "is loaded"
End If
Set f = Nothing
End Sub
<<in Form1>>
Option Explicit
Option Compare Database
Private Sub Command0_Click()
On Error GoTo Err_Command0_Click
Me.Tag = "mytag"
Me.Visible = False
Exit_Command0_Click:
Exit Sub
Err_Command0_Click:
MsgBox Err.Description
Resume Exit_Command0_Click
End Sub