Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms Programming / July 2007

Tip: Looking for answers? Try searching our database.

Listbox to subform refresh  via code

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Ynot - 24 Jul 2007 17:15 GMT
I have a form with a listbox on it and an subform.  The subform is queried
by the selection in the listbox.  All of this works!!

I have added another feature on the form where the rows of the listbox can
be reduced based on a search argument.  I.E. if you want only people with
the last name "Smith" in the listbox, you type Smith into a field and click
a search button.  I use this to alter the data source of the listbox to
include only items with the name "Smith."  That also works perfectly and a
subsequent selection queries the subfiorm and works.

What I want to do is when the results of the search leave only one item in
the listbox, I want that one item to be selected and cause the subform to
requery on that item.   I've tried everything and this is what I currently
have that does not work!

If List0.ListCount = 1 Then

 List0.Selected(0) = True

 Me.RecordsetClone.FindFirst "[ID] = " & Me![List0]

 Me.Bookmark = Me.RecordsetClone.Bookmark

 Form.Refresh

 [FrmMemberData].Requery

End If

What can I do to automatically query the subform if only one item remains in
the listbox??
OldPro - 24 Jul 2007 17:40 GMT
> I have a form with a listbox on it and an subform.  The subform is queried
> by the selection in the listbox.  All of this works!!
[quoted text clipped - 27 lines]
> What can I do to automatically query the subform if only one item remains in
> the listbox??

Instead of [FrmMemberData].Requery, try Forms!Mainformname!
FrmMemberData.Form.Requery where Mainformname is your main form name.
Ynot - 24 Jul 2007 18:36 GMT
Still the same problem.

I changed it.  This is the new statement:

Forms!FrmMemberList!FrmMemberData.Requery

When I select the one item it works just like if there were multiples.  This
is my afterupdate code for the listbox:

Private Sub List0_AfterUpdate()

 Me.RecordsetClone.FindFirst "[ID] = " & Me![List0]

 Me.Bookmark = Me.RecordsetClone.Bookmark

 Form.Refresh

 [FrmMemberData].Requery

End Sub

Any other thoughts?????

>> I have a form with a listbox on it and an subform.  The subform is
>> queried
[quoted text clipped - 37 lines]
> Instead of [FrmMemberData].Requery, try Forms!Mainformname!
> FrmMemberData.Form.Requery where Mainformname is your main form name.
Ynot - 24 Jul 2007 20:26 GMT
It appears that the requery is working, the selection of the single item in
the listbox appears to not be working.  When I manually select it, the
requery in my afterupdate works perfectly.

Just some more info on the problem....

Thanx.

>> I have a form with a listbox on it and an subform.  The subform is
>> queried
[quoted text clipped - 37 lines]
> Instead of [FrmMemberData].Requery, try Forms!Mainformname!
> FrmMemberData.Form.Requery where Mainformname is your main form name.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.