Hi everyone
I'm having a problem with automated a simple requery procedure on a list box on an access form. The problem lies in that I'm requerying this form from a VBA module in another application, not directly from the access application.
The sub in that module performs an ADO recordset operation loading data to a table (works successfully every time) but at times does requery a list box and at times doesn't to reflect the changes in data. I can't seem to figure out why
here's the code that works at it's own wish:
*previous data changes
On Error Resume Next
Set appAcc = GetObject(, "Access.Application")
If Err.Number <> 0 Then
MsgBox "error returning to db"
Exit Sub
End If
Dim form As Access.form
Dim list As Access.Control
For Each form In appAcc.forms
If form.Name = "frmDestinationForm" Then
For Each list In form.Controls
If list.name = "lstDestination" Then
list.Requery
End If
Next
End If
Next
The instantiation never produces an error so that's not the problem. That list box sometimes requery's and sometimes doesn't to reflect the data changes and it's important that it does to the user otherwise the program will appear to be malfunctioning.
The list box's rowsource is based on a query that includes the updated table. Perhaps there's something I could do like run that with code first, or i could approach requerying the list box or manipulating access in a different way?? anything would help
thanks
I'm having a problem with automated a simple requery procedure on a list box on an access form. The problem lies in that I'm requerying this form from a VBA module in another application, not directly from the access application.
The sub in that module performs an ADO recordset operation loading data to a table (works successfully every time) but at times does requery a list box and at times doesn't to reflect the changes in data. I can't seem to figure out why
here's the code that works at it's own wish:
*previous data changes
On Error Resume Next
Set appAcc = GetObject(, "Access.Application")
If Err.Number <> 0 Then
MsgBox "error returning to db"
Exit Sub
End If
Dim form As Access.form
Dim list As Access.Control
For Each form In appAcc.forms
If form.Name = "frmDestinationForm" Then
For Each list In form.Controls
If list.name = "lstDestination" Then
list.Requery
End If
Next
End If
Next
The instantiation never produces an error so that's not the problem. That list box sometimes requery's and sometimes doesn't to reflect the data changes and it's important that it does to the user otherwise the program will appear to be malfunctioning.
The list box's rowsource is based on a query that includes the updated table. Perhaps there's something I could do like run that with code first, or i could approach requerying the list box or manipulating access in a different way?? anything would help
thanks