Using Access 2016
Form frmEditNewGivings (for editing donations made by donors, or deleting entry made in error
Has subform fsubNewGivings
On the Form, there is a List box containing all the Envelope numbers assigned.
User can select a number from the List box. This opens the subform to donations matching the selected envelope number.
The following code works.
What I want also to do is include a text box above the List Box, where the user can type in the desired envelope number, removing the necessity to scroll down through the List Box.
Here's what I have tried:
This works okay for one entry. But if the editing is completed, and the user enters a new envelope number the subform doesn't change to reflect that entry.
It's as if once the user plugs an entry in that text box, things come to a halt.
What do I have to do to modify the code?
Thanks.
Tom
Form frmEditNewGivings (for editing donations made by donors, or deleting entry made in error
Has subform fsubNewGivings
On the Form, there is a List box containing all the Envelope numbers assigned.
User can select a number from the List box. This opens the subform to donations matching the selected envelope number.
The following code works.
Code:
Private Sub lstEnvelopes_AfterUpdate()
Dim sql As String
On Error GoTo lstEnvelopes_AfterUpdate_Error
sql = "SELECT m.EnvNbr, m.[Date Given], m.Local, m.[M and S], m.Building, m.Memorial, m.Other, m.InMemoryOf, m.ToFund " _
& "FROM tblNewGivings as m " _
& "WHERE m.EnvNbr = Forms!frmEditNewGivings!lstEnvelopes " _
& "ORDER BY m.EnvNbr, m.[Date Given]"
Me.fsubNewGivings.Visible = True
Me.lblEdit.Visible = True
'Me.cmdDelete.Visible = True
'Me.Box8.Visible = True
Me.fsubNewGivings.Form.RecordSource = sql
On Error GoTo 0
Exit Sub
lstEnvelopes_AfterUpdate_Error:
MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure lstEnvelopes_AfterUpdate of VBA Document Form_frmEditNewGivings"
What I want also to do is include a text box above the List Box, where the user can type in the desired envelope number, removing the necessity to scroll down through the List Box.
Here's what I have tried:
Code:
Private Sub txtEnvNbr_AfterUpdate()
On Error GoTo Err_txtEnvNbr_AfterUpdate_Error
Dim sql1 As String
sql1 = "SELECT m.EnvNbr, m.[Date Given], m.Local, m.[M and S], m.Building, m.Memorial, m.Other, m.InMemoryOf, m.ToFund " _
& "FROM tblNewGivings as m " _
& "WHERE m.EnvNbr = Forms!frmEditNewGivings!txtEnvNbr " _
& "ORDER BY m.EnvNbr, m.[Date Given]"
Me.fsubNewGivings.Visible = True
Me.lblEdit.Visible = True
Me.txtEnvNbr = Null
On Error GoTo 0
Exit Sub
Err_txtEnvNbr_AfterUpdate_Error:
MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure txtEnvNbr_AfterUpdate of VBA Document Form_frmEditNewGivings"
End Sub
This works okay for one entry. But if the editing is completed, and the user enters a new envelope number the subform doesn't change to reflect that entry.
It's as if once the user plugs an entry in that text box, things come to a halt.
What do I have to do to modify the code?
Thanks.
Tom