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 / General 1 / June 2006

Tip: Looking for answers? Try searching our database.

SYNC Form to listbox

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
ortaias@hotmail.com - 30 Jun 2006 13:15 GMT
I have a listbox which can display all records or provide a limited
list based on a filter derived from an optiongroup.  The code works
except in the one situation where the listbox filter is changed.  The
problem
appears to be "Me.[List7].Selected(1) = True" which triggers
(sporadically) the click event for List7.  The net effect is that when
I click the option button twice the form does update, but it should do
it in one click.  The
first click correctly updates the listbox, the second click then
updates the form.  The form updates as expected when you scroll
down the listbox entries.  I would like to know how clicking on the
option button
will highlight the first item on the list and bring up the form's data
on just the first click.

Private Sub Frame33_Click()
Select Case Frame33
   Case 0 'show all records
       Me![List7].RowSource = "SELECT [projectnum], [projectname] FROM
projectnumqry; "
   Case Else 'show limited (filtered) list
       Me![List7].RowSource = "SELECT [projectnum], [projectname] FROM
projectnumqry where [type]=[frame33];"
   End Select
[Text29] = [List7].ListCount - 1
DoCmd.GoToControl "[List7]"
Me.[List7].Selected(1) = True   <=======problem line
End Sub
------------------------------------------
Private Sub List7_Click()
Rem Pulls-up the summary form information for the selected project
Me.Recordset.FindFirst "[projectnum] = " & Me.[List7]
Call setcontrols
End Sub
Jeff L - 30 Jun 2006 15:08 GMT
Requery List7 after you set the Row Source:  Me.List7.Requery
Call the click option for List7:  Call List7_Click
ortaias@hotmail.com - 30 Jun 2006 16:22 GMT
> Requery List7 after you set the Row Source:  Me.List7.Requery
> Call the click option for List7:  Call List7_Click

Still takes two clicks on the option button to sync. Modified code:
--------------------------------------------------------
DoCmd.GoToControl "[List7]"
Me![List7].Requery
Call List7_Click
Me.[List7].Selected(1) = True
-----------------------------------------------------------
Conceptually, what you have suggested should have worked, since it adds
a "click".  However, if I try it after "Me.[List7].Selected(1) = True",
I get an an error message that the action was cancelled by an undefined
object. The reason for attempting to put "click" after
"Me.[List7].Selected(1) = True" is that this where the code hangs
(requires the double click).  Prior to this line the value of the first
entry has not yet been selected so a click would be on value that had
not yet been established.

I am thinking of an alternative approach, that being a cloned recordset
based on the option box criteria and then displaying the first record.
I am reading one of the programming books on how to use a cloned
recordset.
ortaias@hotmail.com - 30 Jun 2006 17:01 GMT
I ran debug.print
----------------------------------------------------------------------------
CLICK7 Executed - List7=    20040012
CLICK7 Executed - List7=    20040012
Before Me.[List7].Selected(1) is executed= 20040012
After Me.[List7].Selected(1) is executed= 20040012
------------------------------------------------------------------------------
It would appear that "Me.[List7].Selected(1)" causes "CLICK7" to
execute before it is iteself executed.  A problem whith that
intepretation is how LIST7 would get the value "20040012"???
ortaias@hotmail.com - 30 Jun 2006 19:27 GMT
I revised the program to "Call_Click7" and execute
"Me.[List7].Selected(1)". In theory it should have taken care of the
double clidk problem, but now I get an error message that the operation
was canceled by an associated object.
---------------------------------------------------------------------------------------------------------------
Private Sub Frame33_Click()
Select Case Frame33
   Case 0 'show all records
       Me![List7].RowSource = "SELECT [projectnum], [projectname] FROM
projectnumqry; "
   Case Else 'show limited (filtered) list
       Me![List7].RowSource = "SELECT [projectnum], [projectname] FROM
projectnumqry where [type]=[frame33];"
   End Select
[Text29] = [List7].ListCount - 1
DoCmd.GoToControl "[List7]"
frame33ran = True
Call List7_Click
End Sub

Private Sub List7_Click()
Rem Pulls-up the summary form information for the selected project
If Frame33 Then Me.[List7].Selected(1) = True: frame33ran = False
Me.Recordset.FindFirst "[projectnum] = " & Me.[List7]
Call setcontrols
End Sub
Jeff L - 30 Jun 2006 20:33 GMT
Trying something a little different:

Private Sub Frame33_Click()
Select Case Frame33
   Case 0 'show all records
       Me![List7].RowSource = "SELECT [projectnum], [projectname] FROM

projectnumqry; "
   Case Else 'show limited (filtered) list
       Me![List7].RowSource = "SELECT [projectnum], [projectname] FROM

projectnumqry where [type] = " & Me.Frame33 & ";"
   End Select
[Text29] = [List7].ListCount - 1
Me.List7.SetFocus
Call List7_Click
End Sub
------------------------------------------
Private Sub List7_Click()
Rem Pulls-up the summary form information for the selected project
Me.Recordset.FindFirst "[projectnum] = " & Me.[List7]
Call setcontrols
End Sub
ortaias@hotmail.com - 30 Jun 2006 21:47 GMT
In theory, everything should work, but I am still stuck with double
clicking. I think that the "[List7].Selected(1)" statement creates a
pending action that is not cleared.  I think I will just add a note at
the top of the optionbox to click twice.  Even if a person does not
click twice, clicking on the listbox syncs the form. So it self
corrects easily.  Other than the mental excercise of solving the
problem, its not worth the time since a simple double click works.
Also it is quiting time, and I won't be back till July 5th. Thanks very
much for your advice and the realy good tips.  They will be useful.
 
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.