Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: Beginning Access 2003 VBA
This is the forum to discuss the Wrox book Beginning Access 2003 VBA by Denise M. Gosnell; ISBN: 9780764556593
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning Access 2003 VBA section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old September 4th, 2009, 05:33 AM
Registered User
 
Join Date: Aug 2009
Location: Italy - Milan
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Addnew record

Hi at all
I'm new on wrox p2p forum
I read the chapter 5 of this book and in particular the section regarding "building an unbound form"

I'm interested to create a button "add new record" on a extisting bounded form and use it instead of standard buttons, without writing "populateControlsonform" routine, because in my form I've got a submask and a lot of "Combo" controls.

I'm tried to use the "addnew" method, but without success: the record is created, but I'm not able to modify it: when I enter in the first field, I can add chars but I can't exit from the filed and pass to next field


thanks



Private Sub Form_Load()
Dim cnCh5 As ADODB.Connection

Dim strConnection As String
strConnection = "Provider=Microsoft.jet.OLEDB.4.0;" & _
"Data source=" & CurrentProject.Path & "\Chap_05_mio_esercizio.mdb;"

Set cnCh5 = New ADODB.Connection
cnCh5.Open strConnection

Set rsContacts = New ADODB.Recordset

With rsContacts
.CursorType = adOpenKeyset
.CursorLocation = adUseClient
.LockType = adLockOptimistic
.Open "select * from tblContacts", cnCh5
End With

If rsContacts.BOF And rsContacts.EOF Then
MsgBox "There are no records in the db"
Else
Set Me.Recordset = rsContacts
End If
Me.txtLastName.ControlSource = "txtLastName"
Me.txtFirstName.ControlSource = "txtFirstName"
Me.txtMiddleName.ControlSource = "txtMiddleName"
'Me.txtContactId.ControlSource = "intContactId"


End Sub

Private Sub cmdMoveNext_Click()
If Not rsContacts.EOF Then
rsContacts.MoveNext
End If
End Sub

Private Sub cmdAddNew_Click()
rsContacts.AddNew
End Sub
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Help regarding Addnew Kaustav Classic ASP Databases 8 January 10th, 2010 05:33 PM
AddNew with SQL Server... neo_jakey Classic ASP Databases 0 April 16th, 2008 01:26 PM
Addnew with oracle mail4nrs Classic ASP Databases 0 August 23rd, 2004 10:10 AM
addnew problem ponywang@hotmail.com Classic ASP Basics 6 February 24th, 2004 12:08 AM
addnew method jesuseyi Classic ASP Databases 1 August 27th, 2003 02:46 AM



All times are GMT -4. The time now is 10:09 PM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.