By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
428,705 Members | 1,301 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 428,705 IT Pros & Developers. It's quick & easy.

SYNC Form to listbox

P: n/a
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

Jun 30 '06 #1
Share this Question
Share on Google+
6 Replies


P: n/a
Requery List7 after you set the Row Source: Me.List7.Requery
Call the click option for List7: Call List7_Click

Jun 30 '06 #2

P: n/a

Jeff L wrote:
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.

Jun 30 '06 #3

P: n/a
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"???

Jun 30 '06 #4

P: n/a
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

Jun 30 '06 #5

P: n/a
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

Jun 30 '06 #6

P: n/a
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.

Jun 30 '06 #7

This discussion thread is closed

Replies have been disabled for this discussion.