I use the following code to add a new record to a database. It works fine sometimes. Sometimes after requerying the table it understands the first record entered to be the last. Has anybody had similar problems? Does anybody know how th docmd.gotorecord,,acfirst works?
Any help, much appreciated.
Rob
' Insert the next row to the line table
DoCmd.SetWarnings False
DoCmd.RunSQL ("insert into ENG_LINE ( [SITE_ID],[LINE_CNT_ID]) values ('" & Me![SITE_ID] & "'," & NoLines + 1 & "
"
DoCmd.SetWarnings True
' Requry the table
Me.Requery
' Move to the last record
DoCmd.GoToRecord , , acLast
' Set the line variables
NoLines = NoLines + 1
CurrentLine = NoLines
' Update the button status
Call UpdateButtons
Any help, much appreciated.
Rob
' Insert the next row to the line table
DoCmd.SetWarnings False
DoCmd.RunSQL ("insert into ENG_LINE ( [SITE_ID],[LINE_CNT_ID]) values ('" & Me![SITE_ID] & "'," & NoLines + 1 & "
DoCmd.SetWarnings True
' Requry the table
Me.Requery
' Move to the last record
DoCmd.GoToRecord , , acLast
' Set the line variables
NoLines = NoLines + 1
CurrentLine = NoLines
' Update the button status
Call UpdateButtons