I edited and entered the code for both list boxes and got
the following error when I click on the firt value in list
box 1 to send to list box 2: "The macro (or its macro
group) doesn't exist or the macro is new but hasn't been
saved. Note that when you enter the
macrogroupname.macroname syntax in an argument, you must
specify the name the macro's macro group was last saved
under." Am I missing a macro??? Here's the code I put
in:
DoCmd.SetWarnings False
DoCmd.RunSQL "UPDATE FSCa SET FSCa.Selected = True _
Where FSCa.SSAN = " & Me!List0 & ";"
DoCmd.SetWarnings True
Me!List0.Requery
Me!List2.Requery
Put the following code in the AfterUpdate event of the
second listbox:
DoCmd.SetWarnings False
DoCmd.RunSQL "UPDATE FSCa SET FSCa.Selected = False _
Where FSCa.NameOfPKField = " & Me!List2 & ";"
DoCmd.SetWarnings True
Me!List2.Requery
Me!List0.Requery
I named the field "Selected" and made it to a yes/no. Any
ideas??? Thanks.
-----Original Message-----
Both list boxes need to be populated by queries based on the same table. Go
back to that table and add a field named Selected and make it Yes/No.
Include the Selected Field in both queries. In the query for the first
listbox, set the criteria for Selected False. In the query for the second
listbox, set the criteria for Selected True. Put the following code in the
AfterUpdate event of the first listbox:
DoCmd.SetWarnings False
DoCmd.RunSQL "UPDATE NameOfYourTable SET
NameOfYourTable.Selected = True _
Where NameOfYourTable.NameOfPKField = " & Me! NameOfFirstListBox & ";"
DoCmd.SetWarnings True
Me!NameOfFirstListBox.Requery
Me!NameOfSecondListBox.Requery
Put the following code in the AfterUpdate event of the second listbox:
DoCmd.SetWarnings False
DoCmd.RunSQL "UPDATE NameOfYourTable SET
NameOfYourTable.Selected = False _