473,394 Members | 1,699 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Detect when Form is in Add New Record mode

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
Jun 25 '07 #1
3 2394
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
Jun 25 '07 #2
Rory Becker wrote:
>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

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
Jun 25 '07 #3
Rory Becker wrote:
>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


Thanks for you help...

Just figured it out... :D

Cheers
Chris
Jun 25 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: P | last post by:
Hi, I have a form with several controls. One of them is initialized through VB in frm_current. I am using the frm_beforeupdate event to prompt users for saving changes. How can I make it so that...
2
by: MIG | last post by:
Is there a way that, when using a single or continuous form which allows additions and edits, I can detect when I am entering a new record (eg moved on to *) rather than editing an existing one? ...
1
by: thomasamillergoogle | last post by:
I have a site that sometimes gets extremely high server loads. I would like to make it so if the sustained server load is very high (million page views per hour) then it will switch to text only...
0
by: ApexData | last post by:
Hello I launch the Find Dialog Box from a button on a form. How can I determine specifically when the Find Dialog Box is no longer being displayed? This will allow me to control my Button...
7
by: Sam | last post by:
Hello All, We want our Call Service Representatives to be able to go back and view all the records in a table on a form. When closing and re-opening the form the form starts out as record 1 of 1...
4
by: Dst | last post by:
This is what i'm trying to do: I'm porting a windows app to a web app. I have a webform which will edit some data stored in a database. The data needs to be locked in the database, while editing....
2
by: bobh | last post by:
Hi All, In AccessXP on the main menu screen I give the user the option to open this form in either Edit or Read-Only mode. When the user chooses read-only which I use the following line ...
4
by: Tom_F | last post by:
To comp.databases.ms.access -- I know that the recommended way to detect an update to a form, is to use the form's "Before Update" event, and putting in VBA code like: Private Sub...
5
by: Bob Bridges | last post by:
Start with two tables, parent records in one and child records in the other, a one-to-many relationship. Create a select statement joining the two. Display the query in datasheet mode. When I...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.