Results 1 to 11 of 11

Thread: [RESOLVED] How to search month range from MS Access?

  1. #1

    Thread Starter
    Member
    Join Date
    Feb 2006
    Posts
    61

    Resolved [RESOLVED] How to search month range from MS Access?

    How to search a month range from MS Access and display the result in VB data report. For example i want to search all the records from the month of April and it will display the results in VB data report.

    Please help me...

  2. #2
    Fanatic Member eimroda's Avatar
    Join Date
    Jul 2000
    Location
    Philippines
    Posts
    642

    Re: How to search month range from MS Access?

    you can let hte user to input two dates (you can use datetime picker) then in your SQL:

    .... WHERE DateField Between 'date1' AND 'date2'
    of course, date1 and date2 are dates coming from your date time pickers
    On Error GoTo Hell

    Hell:
    Kill Me


    Food For Thought:

    - Do not judge a book... if you're not a judge!


  3. #3

    Thread Starter
    Member
    Join Date
    Feb 2006
    Posts
    61

    Re: How to search month range from MS Access?

    Sorry eimroda but i'm new to all this. Can you please give me an example.

    Thanks alot hope you can help me.

  4. #4
    Fanatic Member eimroda's Avatar
    Join Date
    Jul 2000
    Location
    Philippines
    Posts
    642

    Re: How to search month range from MS Access?

    are you using the data environment?
    On Error GoTo Hell

    Hell:
    Kill Me


    Food For Thought:

    - Do not judge a book... if you're not a judge!


  5. #5

    Thread Starter
    Member
    Join Date
    Feb 2006
    Posts
    61

    Exclamation Re: How to search month range from MS Access?

    Yes i'm using data environment. Can i search the date range and display it in data report? Previously i wanted to display the search result to MSFlexGrid then to data report but fail. Hope you can help me.

    Please i need help urgently. I only have less than 24 hours to my final presentation.

  6. #6
    Fanatic Member eimroda's Avatar
    Join Date
    Jul 2000
    Location
    Philippines
    Posts
    642

    Re: How to search month range from MS Access?

    wait... i'll make a sample project for you...
    On Error GoTo Hell

    Hell:
    Kill Me


    Food For Thought:

    - Do not judge a book... if you're not a judge!


  7. #7
    Addicted Member Redangel's Avatar
    Join Date
    Oct 2005
    Location
    England
    Posts
    214

    Re: How to search month range from MS Access?

    dont know if this will help but i loop though my records to search for a name enterd by the user

    VB Code:
    1. Private Sub txtSearch_KeyDown(KeyCode As Integer, Shift As Integer)
    2. 'Search database for a client
    3. Dim MSG, Style, Title, Response
    4. Dim i As Integer
    5.     If KeyCode = 13 Then    'Enter button
    6.         If txtSearch.Text = "" Then
    7.             MsgBox "Please enter a client's name to search for", vbInformation, "Search Results"
    8.             txtSearch.SetFocus
    9.             Exit Sub
    10.         End If
    11.     Else: Exit Sub
    12.     End If
    13.     txtSearch_Validate True    'Got to the sub to validate text input
    14.     dtaClients.Recordset.MoveLast
    15.     dtaClients.Recordset.MoveFirst
    16.     For i = 0 To dtaClients.Recordset.RecordCount - 1
    17.         If dtaClients.Recordset.Fields("Name") = txtSearch.Text Then
    18.             txtSearch.Text = ""
    19.             txtSearch.Visible = False
    20.             Exit For
    21.         ElseIf dtaClients.Recordset.RecordCount - 1 = i Then
    22.             MSG = "No match found! Please check name is spelled correctly" & _
    23.                     vbCrLf & vbCrLf & "Would you like to create a new search?"
    24.             Style = vbYesNo + vbInformation
    25.             Title = "Search Results"
    26.             Response = MsgBox(MSG, Style, Title)
    27.             If Response = vbYes Then
    28.                 txtSearch_Validate False
    29.                 txtSearch.SetFocus
    30.             Else: txtSearch.Text = ""
    31.                     txtSearch_Validate False
    32.                     txtSearch.Visible = False
    33.             End If
    34.         Else: dtaClients.Recordset.MoveNext
    35.         End If
    36.     Next i
    37. End Sub

    if i helped then please rate my post

  8. #8
    Fanatic Member eimroda's Avatar
    Join Date
    Jul 2000
    Location
    Philippines
    Posts
    642

    Re: How to search month range from MS Access?

    ok try this...
    Attached Files Attached Files
    On Error GoTo Hell

    Hell:
    Kill Me


    Food For Thought:

    - Do not judge a book... if you're not a judge!


  9. #9

    Thread Starter
    Member
    Join Date
    Feb 2006
    Posts
    61

    Thumbs up Re: How to search month range from MS Access?

    Thanks alot eimroda

    Your sample really works. Now i can complete my system and do my presentation. Wish me luck ok.

    Thanks again and Have a nice day

  10. #10
    Fanatic Member eimroda's Avatar
    Join Date
    Jul 2000
    Location
    Philippines
    Posts
    642

    Re: How to search month range from MS Access?

    ur welcome! Good Luck buddy!

    (now u can mark this thread RESOLVED
    On Error GoTo Hell

    Hell:
    Kill Me


    Food For Thought:

    - Do not judge a book... if you're not a judge!


  11. #11

    Thread Starter
    Member
    Join Date
    Feb 2006
    Posts
    61

    Thumbs up Thanks to all who have help me!!!!

    Hai you guys!!! Thank you so much. My presentation yesterday was a success. Thanks to all of you who had help me so much in completing my project. VBForums is the BEST!!!!!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width