Page 2 of 2 FirstFirst 12
Results 16 to 19 of 19
  1. #16
    RedGoneWILD is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Jun 2010
    Posts
    105
    okay...so this is sort of working, but not entirely

    Here's the code i'm using for the after update event

    Code:
     
    Private Sub cboStatus_AfterUpdate()
        Dim db As DAO.Database
        Dim qdf As DAO.QueryDef
        Set db = CurrentDb
        Set qdf = db.QueryDefs("qryStudentList")
        Dim sqlStr As String
        
        selectStatus = Me.cboStatus.Value
        If selectStatus = "All" Then
            sqlStr = "SELECT tblGradStudents.* FROM tblGradStudents ORDER BY tblGradStudents.LastName, tblGradStudents.FirstName;"
        Else
            sqlStr = "SELECT tblGradStudents.* FROM tblGradStudents WHERE tblGradStudents.Status = '" & selectStatus & "' ORDER BY tblGradStudents.LastName, tblGradStudents.FirstName;"
        End If
        
        qdf.SQL = sqlStr
        
        If selectStatus = "All" Then
            'Me.Filter = vbNullString
            Me.FilterOn = True
            Me.FilterOn = False
        Else
            Me.Filter = "Status = " & selectStatus
            Me.FilterOn = True
            Me.FilterOn = False
        End If
        
        Set qdf = Nothing
        Set db = Nothing
        
        setTitle (selectStatus)
    End Sub
    I have the if statement because "All" is not a status and it would crash...All is supposed to essentially remove any filter and display all records

    with the way it is written above, the datasheet in the split form will refresh, or filter, when the combobox is changed...with the exception of the very first time it is changed after the form is opened. The first time it changes i get a "Enter Parameter Value" msgbox with the identifier being whatever option was selected in the combobox. So if I select "Active" in the combobox, then the identifier is "Active"...If cancel is selected instead of OK, then the program crashes...but if OK is selected, then it filters the datasheet and I dont have to worry about the "Enter Parameter Value" msgbox again as long as the form remains open.



    When I switch to design view, the Filter property says 'Status = Active', or whatever the first option was that I selected in the combobox. This remains whatever the first option I selected was, even if I change the combobox several times afterward.

    Also, the "All" selection does not work if something is not in the filter property.

  2. #17
    RedGoneWILD is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Jun 2010
    Posts
    105
    hate to bump this, but i havent been able to figure out what exactly is going wrong

    hoping that somebody might have encountered this before

  3. #18
    weekend00 is offline I may not be right
    Windows XP Access 2003
    Join Date
    Aug 2010
    Posts
    1,295
    Maybe you can try Form.RecordSource = "query name"

  4. #19
    RedGoneWILD is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Jun 2010
    Posts
    105
    weekend is my hero!

    the key here was to set the rowsource to the query name after updating it...then turning off & on the filters so that the form refreshes...works perfectly now and it was just one line of code that needed changed

Page 2 of 2 FirstFirst 12
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Problems with subform refresh
    By Viggen66 in forum Queries
    Replies: 2
    Last Post: 02-23-2010, 04:07 AM
  2. Refresh All goes back to First Record
    By diane802 in forum Forms
    Replies: 4
    Last Post: 12-30-2009, 04:24 PM
  3. Refresh a list box
    By Orabidoo in forum Forms
    Replies: 9
    Last Post: 04-17-2009, 04:07 PM
  4. refresh datasheet as text changes
    By mkhan in forum Forms
    Replies: 0
    Last Post: 09-06-2008, 07:46 AM
  5. Refresh form search text box
    By oxicottin in forum Forms
    Replies: 2
    Last Post: 11-19-2007, 02:28 PM

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