N
nottarealaddress
I'm trying to get my feet wet in VB2005 (our new standard at work
after officially stopping new development in VB6 about a month ago).
I'm working with a simple sql 2005 table of 50 entries, one for each
state. Each entry contains Name, postal abbreviation, etc. Just simple
stuff to understand the mechanisms, syntax, etc.
I'm now to the point where I've got a Master MDI form that opens one
or more types of forms, I'm able to edit/save the data and even return
a "Fail" if another user has altered the record by checking the
rowversion/timestamp field.
My current task is trying to poll all the open forms to check a
property unique to that type of form so I can exclude it from the new
open list.
My frmState2 has a public property of .Key which consists of the two-
letter USPS state code; AL, AK, etc. When a new instance of frmState2
is created, I set frmState2.Key to the two letter code and when the
new instance of the form loads, it gets the Me.Key property and is
able to take it from there.
Now, in the frmOpen's routine to fill the Listbox of state names, I'd
like to tack on a WHERE clause to the SQL statement to exlude the
states already open. (The first time through all 50 states show up,
the next time frmOpen is invoked and fills its listbox, it should only
present 49 states, etc.)
To do this I should (be able to) ripple through the open forms and
compile a list of state codes. My problem is accessing the .Key
property.
I'm currently trying:
For Each f As Form In My.Application.OpenForms
If f.Name = "frmState2" Then
MsgBox(f.Key) 'Just to check what I'm referencing
for right now.
End If
Next
I put in the qualifier checking the f.Name since not every type of
form has a .Key property. However, the compiler won't even let me run
it because "'Key' is not a member of 'System.Windows.Forms.Form'".
Multiple instances of frmState2 are not the only form(s) open, I'll
have the mastermdi and frmOpen as well, so not all the forms will have
a .Key property.
I could do this in VB6 because of the "If f.Name" qualifier. I'm going
to need this "type of thing" later to execute each instance's save
routine in case the user closes the application without saving to save
all the data.
There's got to be a way to reference all the instances of this
property!
-Scott
after officially stopping new development in VB6 about a month ago).
I'm working with a simple sql 2005 table of 50 entries, one for each
state. Each entry contains Name, postal abbreviation, etc. Just simple
stuff to understand the mechanisms, syntax, etc.
I'm now to the point where I've got a Master MDI form that opens one
or more types of forms, I'm able to edit/save the data and even return
a "Fail" if another user has altered the record by checking the
rowversion/timestamp field.
My current task is trying to poll all the open forms to check a
property unique to that type of form so I can exclude it from the new
open list.
My frmState2 has a public property of .Key which consists of the two-
letter USPS state code; AL, AK, etc. When a new instance of frmState2
is created, I set frmState2.Key to the two letter code and when the
new instance of the form loads, it gets the Me.Key property and is
able to take it from there.
Now, in the frmOpen's routine to fill the Listbox of state names, I'd
like to tack on a WHERE clause to the SQL statement to exlude the
states already open. (The first time through all 50 states show up,
the next time frmOpen is invoked and fills its listbox, it should only
present 49 states, etc.)
To do this I should (be able to) ripple through the open forms and
compile a list of state codes. My problem is accessing the .Key
property.
I'm currently trying:
For Each f As Form In My.Application.OpenForms
If f.Name = "frmState2" Then
MsgBox(f.Key) 'Just to check what I'm referencing
for right now.
End If
Next
I put in the qualifier checking the f.Name since not every type of
form has a .Key property. However, the compiler won't even let me run
it because "'Key' is not a member of 'System.Windows.Forms.Form'".
Multiple instances of frmState2 are not the only form(s) open, I'll
have the mastermdi and frmOpen as well, so not all the forms will have
a .Key property.
I could do this in VB6 because of the "If f.Name" qualifier. I'm going
to need this "type of thing" later to execute each instance's save
routine in case the user closes the application without saving to save
all the data.
There's got to be a way to reference all the instances of this
property!
-Scott