Results 1 to 4 of 4
  1. #1
    rankhornjp is offline Advanced Beginner
    Windows Vista Access 2007
    Join Date
    Jul 2011
    Posts
    46

    Calling for parameter that doesn't exist anymore

    I have a form that list people who are having a drug test.



    "Drug Test" is a tab(page) on the "Main" form.
    [TestFilter] is a text box

    The orginal code looked like this.
    Code:
     
    Private Sub TestFilter_Exit()
    Dim sql As String
     
    sql = "SELECT TestResults.ID, People.ID, People.pLname AS [Last Name], People.pFname as [First Name], People.pDOB as [DOB], Tests.tDescription as [Test], [classes]![cDate] AS [Scheduled], TestResults.rResults as [Results] " _
        & "FROM qryGetScheduledDrugTests " _
        & "WHERE (((IIf([cDate] = [TestFilter], Yes, No)) = Yes)) " _
        & "ORDER BY People.pLname;"
     
    Me.lstTestList.RowSource = sql
    End Sub
    This worked fine, except you had to put the date in 3 different places cause "qryGetScheduledDrugTests" uses [FromDate] and [ThruDate] as part of the criteria and they are located on the "Reports" tab of the "Main" form. So, I decided that having the extra [TestFilter] box on the form was unnecessary and made the form less intuitive so I deleted it and changed my code to this:

    Code:
     
    Private Sub DrugTest_Click()
    Dim sql As String
     
    sql = "SELECT TestResults.ID, People.ID, People.pLname AS [Last Name], People.pFname as [First Name], People.pDOB as [DOB], Tests.tDescription as [Test], [classes]![cDate] AS [Scheduled], TestResults.rResults as [Results] " _
        & "FROM qryGetScheduledDrugTests " _
        & "ORDER BY People.pLname;"
     
    Me.lstTestList.RowSource = sql
    End Sub
    Now everytime the the "Main" form loads/refreshes or I switch to the "Drug Test" tab a pop up box asks me for the value of the [TestFilter] parameter. I have searched the whole form, by looking at the property sheet, and all the code, using ctrl+f, for [TestFilter] and came up empty. I don't know why it thinks it's still there.

    I have tried adding back [TestFilter] and then changing it to visible="No". This stops the pop up, but then my list wont populate.

    If I add a date value to the pop-up the list will populate the test that are equal to the value in the pop-up.


    Any suggestions

  2. #2
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726
    Post the sql for this query
    qryGetScheduledDrugTests

  3. #3
    rankhornjp is offline Advanced Beginner
    Windows Vista Access 2007
    Join Date
    Jul 2011
    Posts
    46
    Code:
     
    SELECT DISTINCT [plname] & ", " & [pFname] AS client, People.pDOB, Tests.tDescription, [classes]![cDate] AS rSheduled, Sysvars.FromDate, Sysvars.ThruDate, Classes.cDescription, Classes.CDate, Classes.cTime, Sysvars.ShowInactive, People.pInactive, EnrollmentHeader.ReferralOffice, EnrollmentHeader.ReferralName, People.pFname, People.pLname, People.ID, TestResults.ID, TestResults.rResults
    FROM Sysvars, EnrollmentHeader INNER JOIN (((TestResults INNER JOIN Tests ON TestResults.tID = Tests.ID) INNER JOIN People ON TestResults.pID = People.ID) INNER JOIN Classes ON TestResults.cID = Classes.ID) ON (EnrollmentHeader.ProgID = Classes.ProgID) AND (EnrollmentHeader.pID = People.ID)
    WHERE (((IIf([cdate]>=[FromDate] And [cdate]<=[thrudate],Yes,No))=Yes) AND ((EnrollmentHeader.DateCompleted) Is Null) AND ((EnrollmentHeader.Terminated) Is Null))
    ORDER BY Classes.cDescription;

  4. #4
    rankhornjp is offline Advanced Beginner
    Windows Vista Access 2007
    Join Date
    Jul 2011
    Posts
    46
    I deleted the "Drug Test" tab and started over. It works fine now. Using this code:

    Code:
    Private Sub DrugTest_Click()
    Dim sql As String
     
    sql = "SELECT TestResults.ID, People.ID, People.pLname AS [Last Name], People.pFname as [First Name], People.pDOB as [DOB], Tests.tDescription as [Test], [classes]![cDate] AS [Scheduled], TestResults.rResults as [Results] " _
        & "FROM qryGetScheduledDrugTests " _
        & "ORDER BY People.pLname;"
     
    Me.lstTestList.RowSource = sql
    End Sub
    Not sure I "Solved" anything. Only thing I can gues is it was an error and the [TestFilter] was a ghost in the system.....

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Form doesn't ask for parameter
    By gbwood in forum Forms
    Replies: 1
    Last Post: 11-23-2011, 07:17 PM
  2. VBA to create PDF and folder if doesn't exist!
    By crxftw in forum Programming
    Replies: 2
    Last Post: 08-08-2011, 08:53 AM
  3. Append if record doesn't exist
    By Lorlai in forum Queries
    Replies: 1
    Last Post: 06-14-2011, 06:38 PM
  4. Parameter Query doesn't work
    By Kimmie in forum Access
    Replies: 5
    Last Post: 10-07-2010, 01:30 PM
  5. Form doesn't exist
    By Back2Basics in forum Access
    Replies: 1
    Last Post: 02-01-2010, 11:39 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums