Link to home
Start Free TrialLog in
Avatar of accesslite_
accesslite_

asked on

ADO Recordset command .AddNew use with form

Hello,

I am developing an Access Project front-end and SQL Server back-end application.  

First I need to display a form which is ready for data entry, so I need to somehow move the recordset to display a new (empty) row.  

Is the following code the best way to display a blank row in a form and then insert a new record?
Private Sub Command3_Click()

    Dim cnn As ADODB.Connection
    Dim rcd As ADODB.Recordset
    Set rcd = New ADODB.Recordset
    Set cnn = CurrentProject.Connection
   
rcd.Open "Select * from Requests", cnn, adOpenKeyset, adLockOptimistic, adCmdText

    DoCmd.GoToRecord , , acNewRec
   
    With rcd
        .AddNew
        !Case_Patient_Num = txtCase_Patient_Num
        .Update
    End With

End Sub

Avatar of sbereli
sbereli

Pretty good way, and safe as well.
ASKER CERTIFIED SOLUTION
Avatar of PsychoDazey
PsychoDazey

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial