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 2 / June 2007

Tip: Looking for answers? Try searching our database.

WhereCondition

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
pompeyjim - 15 Jun 2007 11:31 GMT
Hi all
I recently sent in a post asking about retrieving data from a listbox on a
search form and opening the main form showing only the records selected from
the listbox. Ken Sheridan was kind enough to send me this bit of code:
   Dim varItem As Variant
   Dim strEmployeeIDList As String
   Dim strCriteria As String
   Dim ctrl As Control
   
   Set ctrl = Me.lstEmployees
   
   If ctrl.ItemsSelected.Count > 0 Then
       For Each varItem In ctrl.ItemsSelected
           strEmployeeIDList = strEmployeeIDList & "," &
ctrl.ItemData(varItem)
       Next varItem
       
       ' remove leading comma
       strEmployeeIDList = Mid(strEmployeeIDList, 2)

       strCriteria = "[EmployeeID] In(" & strEmployeeIDList & ")"
       DoCmd.OpenForm "frmMain", WhereCondition:=strCriteria
   Else
       MsgBox "No Employees Selected", vbInformation, "Warning"
   End If

Now, for the most part this code works great, but on the line:
   DoCmd.OpenForm "frmMain", WhereCondition:=strCriteria
I have to admit I haven't got a clue what the WhereConditon should be.
Am I being a bit of a dipstick here and it's something really simple.
Can anyone give me an idea what I have to put please.
cheers
Jim
Bob Quintal - 15 Jun 2007 11:00 GMT
> Hi all
> I recently sent in a post asking about retrieving data from a
[quoted text clipped - 19 lines]
>         strCriteria = "[EmployeeID] In(" & strEmployeeIDList &
>         ")"
              DoCmd.OpenForm "frmMain",
>         WhereCondition:=strCriteria
>     Else
[quoted text clipped - 9 lines]
> have to put please. cheers
> Jim

the line
strCriteria = "[EmployeeID] In(" & strEmployeeIDList & ")"
already puts what's required.
stremployeeIDlist should just look like 12345,34567,44444 (for 3
employee ids selected).

Signature

Bob Quintal

PA is y I've altered my email address.

--
Posted via a free Usenet account from http://www.teranews.com

 
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.