Link to home
Start Free TrialLog in
Avatar of Fordraiders
FordraidersFlag for United States of America

asked on

Is there a better why to quickly add a new record ?

Access 2010 vba
sql server linked  tables

Trying to add a new record...taking a very long time to with code

Set R = CurrentDb.OpenRecordset("dbo_t_nsc_trackcode_trans_time_entry", dbOpenDynaset, dbSeeChanges) ''' CLOCKED HERE FOR  15 SECS  03/06/2018
           '          Set R = CurrentDb.OpenRecordset("SELECT * FROM [dbo_t_nsc_trackcode_trans_time_entry]", dbOpenDynaset, dbSeeChanges)
                     R.AddNew
                    R![NSC_ID_Ref] = Me.NSC_Id
                    R![InProgress_or_Closed_at] = Now()
             R.Update
             R.Close
             Set R = Nothing

Open in new window



Is there a better why to quickly add a new record ?

Thanks fordraiders
ASKER CERTIFIED SOLUTION
Avatar of Dale Fye
Dale Fye
Flag of United States of America image

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
SOLUTION
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
Avatar of Fordraiders

ASKER

Thanks all,
I forgot to add one more field that may be a problem ?  getting a value from main form

'R![opened_at] = Forms!nsc_dataentry.txtReOpened

I cant get the syntax to take
errors below

Dim ttt As date
ttt = Forms!nsc_dataentry.txtReOpened

' trying this 

             If txtCid_Form = Me.NSC_Id Then
          
                 
                 If Forms!nsc_dataentry.txtReOpened.Value <> "" Then
                    strSQL_sql = "INSERT INTO [dbo_t_nsc_trackcode_trans_time_entry](NSC_ID_Ref, [opened_at], InProgress_or_Closed_at)" & vbCrLf
                    strSQL_sql = strSQL_sql & "VALUES (" & Me.NSC_Id & "," & ttt & " , now());"

Open in new window



Thanks !
 User generated image
and User generated imageerror message
SOLUTION
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
Thanks all,
The insert statement was 15 secs...faster..

fordraiders