All
 
I use MS Access 2010.
 
I have code below and created a form with two textboxes where property "control set" is set to "first" and "last" respectively. I enabled the reference "Microsoft ActiveX Data Object 2.8 Library".
 
	
	
	
		
 
When I open the form, it displays the names. I am able to edit these two records. I can go to a third row to add a new record. However, as soon I type something in this third row, I get error message "no current record".
 
How can this be solved?
 
Regars
Ino
 I use MS Access 2010.
I have code below and created a form with two textboxes where property "control set" is set to "first" and "last" respectively. I enabled the reference "Microsoft ActiveX Data Object 2.8 Library".
		Code:
	
	
	Private Sub Addnew(ByRef rstADO As ADODB.Recordset, strFirst As String, strLast As String)
rstADO.Addnew
rstADO.Fields("First") = strFirst
rstADO.Fields("Last") = strLast
rstADO.Update
End Sub
 
Private Sub Form_Load()
Dim cn As ADODB.Connection
Dim strSQL As String
Dim rstADO As ADODB.Recordset
Set rstADO = New ADODB.Recordset
With rstADO
    .Fields.Append "ID", adInteger, , adFldKeyColumn
    .Fields.Append "First", adVarChar, 100, adFldMayBeNull
    .Fields.Append "Last", adVarChar, 100, adFldMayBeNull
 
    .CursorType = adOpenDynamic
    .CursorLocation = adUseClient
    .LockType = adLockOptimistic
    .Open
End With
Addnew rstADO, "John", "Little"
Addnew rstADO, "Bill", "Smith"
Set Me.Recordset = rstADO
End Sub
	When I open the form, it displays the names. I am able to edit these two records. I can go to a third row to add a new record. However, as soon I type something in this third row, I get error message "no current record".
How can this be solved?
Regars
Ino