p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   BOOK: Beginning Access 2003 VBA (http://p2p.wrox.com/forumdisplay.php?f=150)
-   -   Addnew record (http://p2p.wrox.com/showthread.php?t=76055)

andrew009 September 4th, 2009 05:33 AM

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


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"
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
End If
End Sub

Private Sub cmdAddNew_Click()
End Sub

All times are GMT -4. The time now is 01:50 AM.

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