GLese
Registered User.
- Local time
- Today, 06:00
- Joined
- Feb 13, 2018
- Messages
- 52
Can someone look through this code and give a hand? I'm running into an issue where if the user clicks No on the msgbox at the end of the code, nothing is updated in the record. If they click yes, then it will update the record. The message box's purpose is to allow the user to rerun the form or exit back to the main menu. I thought I had it set so that everything was updated and closed out before the user was given the option to exit or rerun the form
(FYI, CloseWind at the end of the code is a macro that closes the active window and opens the main navigation form I have set up)
(FYI, CloseWind at the end of the code is a macro that closes the active window and opens the main navigation form I have set up)
Code:
Private Sub btnPick_Click()
'Saves record through DAO recordset and applies information from unbound boxes on form to the record.
Dim Record As DAO.Recordset
Set Record = CurrentDb.OpenRecordset("Select * from [tblPhySmpRecords] WHERE ID = " & Forms!frmPhySmpPick!txbxPhySmpID.Value)
'Opens Recordset
With Record
If Not .BOF And Not .EOF Then
'Checks that the recordset contains records. If no records exist then code in If statement will not run
If .Updatable Then
'Checks to make sure the record selected is not locked by another user.
.Edit
'Begins the update process
Record![Chemist] = Me.txbxChemist.Value
Record![DatePicked] = Date
Record![TimePicked] = Time()
Record.Update
End If
End If
Record.Close
End With
Set Record = Nothing
Call PlayWaveFile_Complete
Dim LResponse As Integer
'Check to see if user wants to enter another sample
LResponse = MsgBox("Sample sucessfully picked! Do you wish to pick up another sample?", vbYesNo, "Thank You!")
If LResponse = vbYes Then
DoCmd.Close
DoCmd.OpenForm "frmPhySmpPick", acNormal
Else
CloseWind
End If
End Sub