Page 2 of 2 FirstFirst 12
Results 16 to 26 of 26
  1. #16
    Parker is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2014
    Posts
    76
    Ok, so now I have in the window:


    If Me.Combo197 Like "Date*" Then
    Me.Filter = Me.Combo197 & "=#" & Me.Text175 & "#"
    ElseIf Me.Combo197 = "Report_ID" Or Me.Combo197 = "Submitted_By" Or Me.Combo197 = "Reviewed_By" Then
    Me.Filter = Me.Combo197 & "=" & Me.Text175
    Else
    Me.Filter = Me.Combo197 & "='" & Me.Text175 & "'"
    End If
    Me.FilterOn = True


    Im not sure what this means (How do you have that code in the VBA window if it is not already within an event procedure?)

    I would really like to have a button as pictured so once they type in a word they can physically click "search"


  2. #17
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    No wonder this code is not working. The "Search" form does not have a RecordSource - it is unbound. Applying the filter string to that form's Filter property is meaningless.

    If you want to construct the filter string and apply to another form or report. Try:
    Code:
    Private Sub Command164_Click()
    Dim strFilter As String
    If Me.Combo197 Like "Date*" Then
       strFilter = Me.Combo197 & "=#" & Me.Text175 & "#"
    ElseIf Me.Combo197 = "Report_ID" Or Me.Combo197 = "Submitted_By" Or Me.Combo197 = "Reviewed_By" Or Me.Combo197 = "Approved" Then
       strFilter = Me.Combo197 & "=" & Me.Text175
    Else
       strFilter = Me.Combo197 & " LIKE '*" & Me.Text175 & "*'"
    End If
    DoCmd.OpenForm "SearchMainF", , , strFilter
    End Sub
    Be sure to fix the RecordSource of SearchMainF.

    The Submitted_By, Reviewed_By, and Approved fields are number type but you have alias Lookups set up on them in table (I NEVER do that - review http://access.mvps.org/access/lookupfields.htm). Even though you see text when viewing the table the actual value is the foreign key number. The search parameter will have to be the foreign key number ID. More reason for a combobox to input search parameter instead of textbox.

    Are you aware that Access has a 2GB file size limit? Embedding documents in Attachment field can use up that limit fast. Also, can't really filter/search an Attachment field, at least not with this arrangement.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #18
    Parker is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2014
    Posts
    76
    I appreciate your help, but I don't physically know how to do each step your asking. Could you either be more specific in how to do the alias lookups or just PM back the DB amended with the changes?

    Furthermore, maybe I blasted it away when I sent you the non-confidential DB but in the "search" form I have the following in my record source:

    SELECT NewLabReportT.Report_ID, NewLabReportT.Submitted_By, NewLabReportT.Reviewed_By, NewLabReportT.Date_Experiment_Started, NewLabReportT.Date_Experiment_Ended, NewLabReportT.Date_Report_Submitted, NewLabReportT.Experiment_Location, NewLabReportT.Report_Title, NewLabReportT.Report_Document, NewLabReportT.Notes, NewLabReportT.Abstract, NewLabReportT.Approved, NewLabReportT.Report_History FROM NewLabReportT;

    And we are not worried about file size... we will only be uploading .DF smaller than 25kb... we can fit tons of files within the 2GB limit
    Last edited by June7; 05-13-2014 at 08:54 AM.

  4. #19
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    1. You already have the 'lookups' built in the table on those fields. My point was to advise not to do that. Did you review the link?

    2. The 'search' form I was referring to is MainMenuF, the one that opens by default and has the combobox and textbox to construct filter criteria.

    3. The only 'steps' you need to do are to replace the code for the command button and delete unnecessary code. Since you have already created VBA procedure you should know how to edit it.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #20
    Parker is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2014
    Posts
    76
    All I did was copy and paste VBA stuff from these forums lol. I have never been trained or educated in VBA.

  6. #21
    Parker is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2014
    Posts
    76
    Private Sub Command164_Click()
    Dim strFilter As String
    If Me.Combo197 Like "Date*" Then
    strFilter = Me.Combo197 & "=#" & Me.Text175 & "#"
    ElseIf Me.Combo197 = "Report_ID" Or Me.Combo197 = "Submitted_By" Or Me.Combo197 = "Reviewed_By" Or Me.Combo197 = "Approved" Then
    strFilter = Me.Combo197 & "=" & Me.Text175
    Else
    strFilter = Me.Combo197 & " LIKE '*" & Me.Text175 & "*'"
    End If
    DoCmd.OpenForm "SearchMainF", , , strFilter
    End Sub

    Run-time error '2501'

    the OpenForm action was cancled

  7. #22
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Did you fix the RecordSource of SearchMainF? Right now it references a query that doesn't exist.

    Or reference whatever form or report you want that has the appropriate RecordSource.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  8. #23
    Parker is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2014
    Posts
    76
    Your right this says it needs a reference. Do I just delete it? Do I need it?

  9. #24
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    I don't understand. What says you need a reference? Delete what?

    What form or report do you want to open?

    Opening a filtered form or report is basic Access functionality. All the code is doing is automating that functionality with dynamic parameters.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  10. #25
    Parker is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Apr 2014
    Posts
    76
    the form SearchF has nothing to do with SearchMainF. All I have on the main screen is the Combo box, a text box and a button. I have not created a form for the search command yet. That is what I ahve been waiting on with the last code instruction. I sent you a PM earlier today.

  11. #26
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    Build whatever form or report you want then reference it in the suggested code in place of "SearchMainF".
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

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

Similar Threads

  1. Replies: 2
    Last Post: 05-07-2014, 10:24 AM
  2. Replies: 6
    Last Post: 10-26-2012, 09:28 AM
  3. Replies: 3
    Last Post: 08-22-2012, 03:28 AM
  4. Menu bar issue in Access 2010
    By karthikn240687 in forum Access
    Replies: 1
    Last Post: 03-27-2012, 03:22 PM
  5. I can't see the menu options in Ms Access 2010.
    By dave_joseph in forum Access
    Replies: 2
    Last Post: 10-27-2011, 03:11 AM

Tags for this Thread

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