Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 2005 > Visual Basic 2005 Basics
|
Visual Basic 2005 Basics If you are new to Visual Basic programming with version 2005, this is the place to start your questions. For questions about the book: Beginning Visual Basic 2005 by Thearon Willis and Bryan Newsome, ISBN: 0-7645-7401-9 please, use this forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Visual Basic 2005 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 1st, 2007, 02:34 AM
Kia Kia is offline
Authorized User
 
Join Date: Jun 2007
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Default How to add new blank record to data form?

Hi all,

I have a small problem.. I have a databound form with text boxes, checkboxes, combo boxes and buttons that take care of navigation, save, delete... But the "New Record" button gives me trouble.

I want a "New" button that essentially does the same thing as the Binding Navigator. I want to press the button and all the databound fields clear and we're looking at a new record. But I can't find any instructions on doing this.

Here's the code I have so far(which doesn't work right):
    Me.DsMyDatasource.tblMyTable.Rows.Add()

I get error:
    :("Column '...MyMandatoryField...' does not allow nulls."

Obviously its expecting a new record complete with the data. But I want to give the user a chance to enter these details in first, then click on "Save".

Can anyone help me?
Thanks,
Kia
 
Old June 12th, 2007, 02:11 AM
Kia Kia is offline
Authorized User
 
Join Date: Jun 2007
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hmm... seems nobody knows the answer... Lucky I've now found a solutions.

For those who are looking here due to having the same issue, I can point out that the Binding Source is best for most of your record navigation and operations.

Me.bsMyBindingSource.AddNew
    .MoveNext
    .MovePrevious
    ...

.AddNew will move the pointer to a new row.

Kia





Similar Threads
Thread Thread Starter Forum Replies Last Post
Open Form to Add New Record is Blank echovue Access 9 July 10th, 2013 03:38 PM
Add Record to table from form AlForum29 Access VBA 2 January 2nd, 2013 09:46 PM
Add record form bunkerbang Access VBA 5 September 12th, 2007 12:17 AM
add a record to yes/no control form VB carlos1972 Access VBA 2 April 6th, 2006 10:01 PM
how to find record, if not found add in form Sjackson Access 1 May 27th, 2005 10:58 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.