Have a form that contains fields AssociatedProject, AssociatedRelease and then the user hits a button to create a new record and a new form opens to display this newly created record which sets the fields and also sets a field called Type. There is no issue with setting the field values and the new record is created. However, when the form opens to display the record it displays another record instead (usually the one before it). I think it could be related to the fact that the db resides on a shared drive which periodically has slow connectivity. However, I'm looking for a solution, perhaps modifying the code? Any suggestions? Any help is greatly appreciated!
Here's the code:
Private Sub Command17_Click()
Dim strSQL As String
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim ctl As Control
Dim varItem As Variant
On Error GoTo Err_Command17_Click
Set db = CurrentDb()
Set rs = db.OpenRecordset("Tbl_Main", dbOpenDynaset, dbAppendOnly)
'add selected value(s) to table
rs.AddNew
rs!AssociatedProject = Me.[AssociatedProject]
rs!AssociatedRelease = Me.[AssociatedRelease]
rs!Type = 1
rs.Update
DoCmd.OpenForm "Frm_ManageQuestionsAnswersEdit", acNormal, "", "[AssociatedProject]=" & [AssociatedProject], , acNormal
DoCmd.GoToRecord acForm, "Frm_ManageQuestionsAnswersEdit", acLast
ExitHandler:
Set rs = Nothing
Set db = Nothing
Exit Sub
ErrorHandler:
Select Case Err
Case Else
MsgBox Err.Description
DoCmd.Hourglass False
Resume ExitHandler
End Select
Err_Command17_Click:
MsgBox Err.Description
Exit Sub
End Sub
Here's the code:
Private Sub Command17_Click()
Dim strSQL As String
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim ctl As Control
Dim varItem As Variant
On Error GoTo Err_Command17_Click
Set db = CurrentDb()
Set rs = db.OpenRecordset("Tbl_Main", dbOpenDynaset, dbAppendOnly)
'add selected value(s) to table
rs.AddNew
rs!AssociatedProject = Me.[AssociatedProject]
rs!AssociatedRelease = Me.[AssociatedRelease]
rs!Type = 1
rs.Update
DoCmd.OpenForm "Frm_ManageQuestionsAnswersEdit", acNormal, "", "[AssociatedProject]=" & [AssociatedProject], , acNormal
DoCmd.GoToRecord acForm, "Frm_ManageQuestionsAnswersEdit", acLast
ExitHandler:
Set rs = Nothing
Set db = Nothing
Exit Sub
ErrorHandler:
Select Case Err
Case Else
MsgBox Err.Description
DoCmd.Hourglass False
Resume ExitHandler
End Select
Err_Command17_Click:
MsgBox Err.Description
Exit Sub
End Sub