Keeping a referenced form from opening

I have created a standard mod called DBMod that is used to create an Access database on the flay when needed, such as when program is first started or to restore it. Anyhow, to create the Tables, I need to reference the forms that the tables represent to ensure the data is correct.

Example:
I need to reference my frmRanks to tell the DBMod how many txtRank boxs there are by calling
frmRanks.txtRanks.Count
from the DBMod.
Whenever I use this method it Loads the frmRanks, not good!
I tried to use
frmRanks.Visible = false
before any reference calls to it, but the form still blinks on and off, not good!

How can I reference the form controls from a Mod or other form without loading it?

Thanks
Scott.

Full code below.
****************
[code]
Option Explicit
Dim cat As New ADOX.Catalog
Dim tbl As New ADOX.Table


Public Sub CreateDB()
'Create Root Database in Program Directory

cat.Create "Provider=MicroSoft.JET.OLEDB.4.0;" & _
"Data Source=" & App.Path & "cm.mdb;"

End Sub

Public Sub CreateRankTable()
'assemble Ranks Table using frmRanks for source data
Dim idx, total As Integer

With tbl
.Name = "Ranks"
.Columns.Append "RankName", adVarWChar
.Columns("RankName").Attributes = adColNullable
.Columns.Append "RankDescription", adVarWChar
.Columns("RankDescription").Attributes = adColNullable
End With

'Add a Field for each txtRank box on frmRanks named after its Tag Property

total = [blue](frmRanks.txtRank.Count - 1)[/blue] 'Number of txtRank boxs
For idx = 0 To total Step 1
tbl.Columns.Append [blue]frmRanks.txtRank(idx).Tag,[/blue] adVarWChar 'retrieves tag value
tbl[blue](frmRanks.txtRank(idx).Tag)[/blue].Attributes = adColNullable 'allow null values
Next

'add table to Cat
cat.Tables.Append tbl

End Sub

Public Sub AssembleDB()

CreateDB 'Create Root DB
CreateRankTable 'Create the Ranks table

End Sub
[/code]

Comments

  • : I have created a standard mod called DBMod that is used to create an Access database on the flay when needed, such as when program is first started or to restore it. Anyhow, to create the Tables, I need to reference the forms that the tables represent to ensure the data is correct.
    :
    : Example:
    : I need to reference my frmRanks to tell the DBMod how many txtRank boxs there are by calling
    : frmRanks.txtRanks.Count
    : from the DBMod.
    : Whenever I use this method it Loads the frmRanks, not good!
    : I tried to use
    : frmRanks.Visible = false
    : before any reference calls to it, but the form still blinks on and off, not good!
    :
    : How can I reference the form controls from a Mod or other form without loading it?
    :
    : Thanks
    : Scott.
    :
    : Full code below.
    : ****************
    : [code]
    : Option Explicit
    : Dim cat As New ADOX.Catalog
    : Dim tbl As New ADOX.Table
    :
    :
    : Public Sub CreateDB()
    : 'Create Root Database in Program Directory
    :
    : cat.Create "Provider=MicroSoft.JET.OLEDB.4.0;" & _
    : "Data Source=" & App.Path & "cm.mdb;"
    :
    : End Sub
    :
    : Public Sub CreateRankTable()
    : 'assemble Ranks Table using frmRanks for source data
    : Dim idx, total As Integer
    :
    : With tbl
    : .Name = "Ranks"
    : .Columns.Append "RankName", adVarWChar
    : .Columns("RankName").Attributes = adColNullable
    : .Columns.Append "RankDescription", adVarWChar
    : .Columns("RankDescription").Attributes = adColNullable
    : End With
    :
    : 'Add a Field for each txtRank box on frmRanks named after its Tag Property
    :
    : total = [blue](frmRanks.txtRank.Count - 1)[/blue] 'Number of txtRank boxs
    : For idx = 0 To total Step 1
    : tbl.Columns.Append [blue]frmRanks.txtRank(idx).Tag,[/blue] adVarWChar 'retrieves tag value
    : tbl[blue](frmRanks.txtRank(idx).Tag)[/blue].Attributes = adColNullable 'allow null values
    : Next
    :
    : 'add table to Cat
    : cat.Tables.Append tbl
    :
    : End Sub
    :
    : Public Sub AssembleDB()
    :
    : CreateDB 'Create Root DB
    : CreateRankTable 'Create the Ranks table
    :
    : End Sub
    : [/code]
    :


    You have to load the form to use it's method, properties, controls, etc. The only idea I have is to set it's visible property to False at design time. Now when it's loaded, it should never show up.

  • You may attempt placing the needed strings/numbers in public variables in standard modules instead of the Tag properties. This will both increase performances and avoid loading the form.
    _____________________________
    [size=1][b][grey]Cold[/grey][blue]Shine[/blue][/b]
    http://www16.brinkster.com/rafonline[/size]


Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories