G
Gwen H
I have a form with a listbox that is used to select a specific project
request number. Sometimes there are duplicate project request numbers (yes it
needs to be that way). I also have a button to save changes to the currently
selected record. What I want to do is, once a user enters a project close
date and clicks the save button, I want to select the first item in the list
box and/or go to the first record of the form. I also want to requery the
list box, because once a project has a close date it's not supposed to show
in the list box. The query on which the form is based excludes all projects
with a close date. Here's the code I tried to accomplish all this. I'm not
getting any error messages ... I'm just not getting the behavior I want.
'Button to save the changes to the current record
Private Sub saveChanges_Click()
On Error GoTo Err_saveChanges_Click
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
MsgBox "Changes to This Record Have Been Saved", vbOKOnly, "Changes Saved"
Me.Form.Requery
Me.List0.SetFocus
Me.List0.Requery
DoCmd.GoToRecord , , acFirst
Exit_saveChanges_Click:
Exit Sub
Err_saveChanges_Click:
MsgBox Err.description
Resume Exit_saveChanges_Click
End Sub
Thanks!
GwenH
request number. Sometimes there are duplicate project request numbers (yes it
needs to be that way). I also have a button to save changes to the currently
selected record. What I want to do is, once a user enters a project close
date and clicks the save button, I want to select the first item in the list
box and/or go to the first record of the form. I also want to requery the
list box, because once a project has a close date it's not supposed to show
in the list box. The query on which the form is based excludes all projects
with a close date. Here's the code I tried to accomplish all this. I'm not
getting any error messages ... I'm just not getting the behavior I want.
'Button to save the changes to the current record
Private Sub saveChanges_Click()
On Error GoTo Err_saveChanges_Click
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
MsgBox "Changes to This Record Have Been Saved", vbOKOnly, "Changes Saved"
Me.Form.Requery
Me.List0.SetFocus
Me.List0.Requery
DoCmd.GoToRecord , , acFirst
Exit_saveChanges_Click:
Exit Sub
Err_saveChanges_Click:
MsgBox Err.description
Resume Exit_saveChanges_Click
End Sub
Thanks!
GwenH