Detect when Form is in Add New Record mode

  • Thread starter Thread starter Chris @ TechCon
  • Start date Start date
C

Chris @ TechCon

Hi,

I'm a bit of a vb.net newbie. I'm building a application in VS2005 that
will help manage my business. I've got the form working to a extent.
What i want to know is the following:

1. Is there a way i can make a instance of the form load as if i was
creating a new record to append to the bound dataset?

Cheers
Chris
 
I'm a bit of a vb.net newbie. I'm building a application in VS2005
that will help manage my business. I've got the form working to a
extent. What i want to know is the following:

1. Is there a way i can make a instance of the form load as if i was
creating a new record to append to the bound dataset?

Not sure if I understand you Chris but I have a suggestion.

When I have a form that needs to operate in 2 different modes I tend to make
the constructor of said form private so that no external force(Reflection
not withstanding) can create it.

I then create a public Shared Method on the Form for each of the modes that
I need. Each method New's up an instance of the Form and set's a private
enum field on the form to whichever mode this method feels is appropriate.
Then you only need to observe this setting from any code within the form
and should not have to worry about external forces changing this fact.


The only alternative I can see is to create 2 distinct form which both operate
in different ways.
Perhaps even have the decend (inherit) from a 3rd form which could broadly
define the layout.

Now that I look back at your original post, I feel that I might have read
too much into your question, but perhaps this will still prove to be useful
anyway. (You never know:) )
 
Rory said:
Not sure if I understand you Chris but I have a suggestion.

When I have a form that needs to operate in 2 different modes I tend to
make the constructor of said form private so that no external
force(Reflection not withstanding) can create it.
I then create a public Shared Method on the Form for each of the modes
that I need. Each method New's up an instance of the Form and set's a
private enum field on the form to whichever mode this method feels is
appropriate. Then you only need to observe this setting from any code
within the form and should not have to worry about external forces
changing this fact.


The only alternative I can see is to create 2 distinct form which both
operate in different ways. Perhaps even have the decend (inherit) from a
3rd form which could broadly define the layout.

Now that I look back at your original post, I feel that I might have
read too much into your question, but perhaps this will still prove to
be useful anyway. (You never know:) )

Thanks for you help rory, i kinda get what you mean (as mentioned in my
post im kinda vb.net newbie...), but kinda dont.

I'll see if i can explain the problem a little better....

The way i'm thinking of it is like when in VBA for Access and you issue the

DoCmd.OpenForm "frmName", acNormal, , , acFormAdd

command and it opens up the form bound to the data but with blank
controls so that you can immediatley start adding new records...

Or from the vb.net side of things, when using the BindingNavigator
control and clicking on the AddNewItem control to add a new record to
the dataset...

Is there anyway to invoke that type of thing from code?

Does that make more sense?

Cheers
Chris
 
Rory said:
Not sure if I understand you Chris but I have a suggestion.

When I have a form that needs to operate in 2 different modes I tend to
make the constructor of said form private so that no external
force(Reflection not withstanding) can create it.
I then create a public Shared Method on the Form for each of the modes
that I need. Each method New's up an instance of the Form and set's a
private enum field on the form to whichever mode this method feels is
appropriate. Then you only need to observe this setting from any code
within the form and should not have to worry about external forces
changing this fact.


The only alternative I can see is to create 2 distinct form which both
operate in different ways. Perhaps even have the decend (inherit) from a
3rd form which could broadly define the layout.

Now that I look back at your original post, I feel that I might have
read too much into your question, but perhaps this will still prove to
be useful anyway. (You never know:) )


Thanks for you help...

Just figured it out... :D

Cheers
Chris
 
Back
Top