You are currently viewing the BOOK: Beginning Access 2003 VBA section of the Wrox p2p Programmer to Programmer discussion community. This is a community of more than 40,000 computer programmers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining our free Wrox p2p community you can post your own programming questions and respond to other programmers’ questions. Registered users also don't have to see the ads that are displayed to guests. Registration is fast, simple and absolutely free so please, join today!
Join today and post to win prizes! Post more to increase your chances of being Wrox’s top poster of the month.
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