|
 |
access thread: listbox requery
Message #1 by "Ben" <bcb@a...> on Tue, 9 Oct 2001 23:52:52
|
|
I have a list box bound to a table called tblNotes
I then run the following code, which is supposed to delete the selected
note in the listbox:
Private Sub cmdDeleteNote_Click()
Dim rst As DAO.Recordset
currentNote = Me.lstNotes.Column(0)
If currentNote <> vbNull Then
CurrentDb.Execute ("DELETE * FROM tblNotes WHERE Date = " & "#" &
currentNote & "#")
CurrentDb.Recordsets.Refresh
End If
Me!lstNotes.RowSource = ("SELECT [tblNOTES].[DATE], [tblNOTES].[SUBJECT]
FROM tblNOTES;")
Me!lstNotes.Requery
End Sub
The note is deleted in the table but the listbox does not reflect this.
Message #2 by "Sanna Korpela" <sanna.m.korpela@l...> on Wed, 10 Oct 2001 12:49:45
|
|
I have no idea why, but in my solution I use refresh instead of requery
(Me!lstNotes.Requery), and it works. I think you get easy on all theese
refreshing if you just put it in Form_Activate()-sub.
(In every form:
Private Sub Form_Activate()
Form.Refresh
End Sub)
Hope this will help,
Sanna
> I have a list box bound to a table called tblNotes
>
> I then run the following code, which is supposed to delete the selected
> note in the listbox:
>
> Private Sub cmdDeleteNote_Click()
> Dim rst As DAO.Recordset
>
> currentNote = Me.lstNotes.Column(0)
>
> If currentNote <> vbNull Then
> CurrentDb.Execute ("DELETE * FROM tblNotes WHERE Date = " & "#"
&
> currentNote & "#")
> CurrentDb.Recordsets.Refresh
> End If
>
> Me!lstNotes.RowSource = ("SELECT [tblNOTES].[DATE], [tblNOTES].[SUBJECT]
> FROM tblNOTES;")
> Me!lstNotes.Requery
>
> End Sub
>
> The note is deleted in the table but the listbox does not reflect this.
|
|
 |