troubleshooting Question

vba query using multi field listbox

Avatar of nlouder
nlouder asked on
Microsoft Access
4 Comments1 Solution447 ViewsLast Modified:
I have a access form with two list boxes called Available and Chosen the Available list box is populated with 3 fields (Agcno (number), Agency(text) & State(text) from the table TBLAgency.  When a record is selected from the Available listbox and added to the Chosen listbox I would like to update a field called Flag1 for the selected record in my table with a "false" value.  I have used the following vba code which works fine in another database using a single field listbox but is erroring out on the query using the 3 fields listbox.

Private Sub Add_Click()
    If Available.ItemsSelected.Count = 1 Then
        CurrentDb.Execute ("UPDATE TBLAgency SET TBLAgency.FLAG1 = False " & _
        "WHERE TBLAgency.AGCNO AND TBLAgency.AGENCY AND TBLAgency.CITY ='" & Available & "';")
    End If
End Sub

Any ideas or solutions?
Leigh Purvis
Database Developer

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 4 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 4 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros