Results 1 to 6 of 6
  1. #1
    chhinckley is offline Novice
    Windows XP Access 2003
    Join Date
    Aug 2010
    Posts
    4

    strWhere VB Code

    I am having problems with a strWhere code - see below. I am getting an error message on the Me.frmBrowse_All_Programs.Form.Filter = strWhere line of code. What am I doing wrong.

    Private Sub Search_Click()
    Dim strWhere As String
    Dim strError As String

    strWhere = "1=1"
    ' If UCMG Code
    If Not IsNull(Me.UCMGCode) Then
    strWhere = strWhere & " AND " & "frmBrowse All Programs.[UCMG Code] = " & Me.UCMGCode & ""
    End If
    ' If Program Name
    If Not IsNull(Me.ProgramName) Then
    strWhere = strWhere & " AND " & "frmBrowse All Programs.[Program Name] = " & Me.ProgramName & ""
    End If

    If IsNull(strWhere) Then
    MsgBox "No Criteria was selected for search."
    Else
    'DoCmd.OpenForm "Browse Issues", acFormDS, , strWhere, acFormEdit, acWindowNormal
    If Not Me.FormFooter.Visible Then


    Me.FormFooter.Visible = True
    DoCmd.MoveSize Height:=Me.WindowHeight + Me.FormFooter.Height
    End If
    Me.frmBrowse_All_Programs.Form.Filter = strWhere
    Me.frmBrowse_All_Programs.Form.FilterOn = True
    End If
    End Sub

  2. #2
    weekend00 is offline I may not be right
    Windows XP Access 2003
    Join Date
    Aug 2010
    Posts
    1,295
    Please replace the two line with pink.


    Private Sub Search_Click()
    Dim strWhere As String

    Dim strError As String

    strWhere = "1=1"
    ' If UCMG Code
    If Not IsNull(Me.UCMGCode) Then
    strWhere = strWhere & " AND " & " [UCMG Code] = '" & Me.UCMGCode & "'"
    End If
    ' If Program Name
    If Not IsNull(Me.ProgramName) Then
    strWhere = strWhere & " AND " & " [Program Name] = '" & Me.ProgramName & "'"
    End If

    If IsNull(strWhere) Then
    MsgBox "No Criteria was selected for search."
    Else
    'DoCmd.OpenForm "Browse Issues", acFormDS, , strWhere, acFormEdit, acWindowNormal
    If Not Me.FormFooter.Visible Then
    Me.FormFooter.Visible = True
    DoCmd.MoveSize Height:=Me.WindowHeight + Me.FormFooter.Height
    End If
    Me.frmBrowse_All_Programs.Form.Filter = strWhere
    Me.frmBrowse_All_Programs.Form.FilterOn = True
    End If
    End Sub

  3. #3
    chhinckley is offline Novice
    Windows XP Access 2003
    Join Date
    Aug 2010
    Posts
    4

    Re: strWhere Code

    I replaced the pink lines and I am still getting the following error

    Run-time error '2448':

    You can't assign a value to this object.

  4. #4
    weekend00 is offline I may not be right
    Windows XP Access 2003
    Join Date
    Aug 2010
    Posts
    1,295
    the error was not raised by the two lines, find out the error where it raised and correct it.

  5. #5
    chhinckley is offline Novice
    Windows XP Access 2003
    Join Date
    Aug 2010
    Posts
    4

    Re: strWhere VB Code

    The error is being detected in the

    Me.frmBrowse_All_Programs.Form.Filter = strWhere

    I haven't been able to figure out the fix

  6. #6
    weekend00 is offline I may not be right
    Windows XP Access 2003
    Join Date
    Aug 2010
    Posts
    1,295
    that means you can not apply the filter in this way.

    use
    me.recordsource=strwhere
    instead

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

Similar Threads

  1. Code help
    By Alex Motilal in forum Forms
    Replies: 3
    Last Post: 06-17-2010, 07:12 AM
  2. Help with code
    By steve183 in forum Programming
    Replies: 2
    Last Post: 06-04-2010, 05:14 PM
  3. Help with VBA code
    By bgonzal1 in forum Access
    Replies: 3
    Last Post: 12-14-2009, 07:12 AM
  4. Access 2003 code vs Access 2007 Code
    By ralphjramirez in forum Access
    Replies: 5
    Last Post: 11-23-2009, 12:33 PM
  5. Help with VBA Code
    By access.newby in forum Forms
    Replies: 1
    Last Post: 11-15-2009, 05:43 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