Results 1 to 7 of 7
  1. #1
    deepaksharma is offline Competent Performer
    Windows 7 32bit Access 2016
    Join Date
    Jul 2023
    Location
    india
    Posts
    389

    Some coding help!!!

    My greetings to all of you.



    I have created two forms in the attached program, one form shows the data list and the other form works to show date wise records.
    For some reason the date wise search form (SearchS) is not working properly. I tried a lot but I can't find the reason properly.

    Apart from this, when the search form (SearchF2) is opened directly, an arrow is showing in the column of offerDate, I am not able to remove it also. Please help me.
    Thank you.
    Attached Thumbnails Attached Thumbnails ssUntitled.png  
    Attached Files Attached Files

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Form OrderBy is set with [SearchQ].[OfferDate] and OrderByOnLoad is set to yes.
    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. #3
    deepaksharma is offline Competent Performer
    Windows 7 32bit Access 2016
    Join Date
    Jul 2023
    Location
    india
    Posts
    389
    Quote Originally Posted by June7 View Post
    Form OrderBy is set with [SearchQ].[OfferDate] and OrderByOnLoad is set to yes.
    Thank you very much June.

    Due to your suggestion the arrow shown in the picture has now been removed but why is the SearchS form not showing date wise results please help me.
    Thank you.

  4. #4
    Join Date
    May 2018
    Location
    Living in Scotland UK
    Posts
    1,566

    Code Help

    Hi

    I created a copy of your SearchQ Form and named it frmSearchResult

    I removed the criteria from SearchQ

    Then I modified the OnClick Event on your SearchS Form
    Attached Files Attached Files
    You can PM me if you need further help.
    Good Reading https://docs.microsoft.com/en-gb/off...on-description

  5. #5
    deepaksharma is offline Competent Performer
    Windows 7 32bit Access 2016
    Join Date
    Jul 2023
    Location
    india
    Posts
    389
    Quote Originally Posted by mike60smart View Post
    Hi

    I created a copy of your SearchQ Form and named it frmSearchResult

    I removed the criteria from SearchQ

    Then I modified the OnClick Event on your SearchS Form
    hello mike
    Thank you very much for your help.
    I replaced my code with your code and my problem was solved.
    Can you please explain what is the difference between these two codes and what is the function of your third code with if statement.
    Thanks again.

    My code
    Code:
        Dim strwhere        As Integer
        strwhere = "Offerdate BETWEEN #" & Me.cbxStart & "# And #" & Me.cbxend & "#"
        DoCmd.OpenForm "searchf2", acNormal, , strwhere
        DoCmd.Close acForm, "searchs"
    Your's Code
    Code:
              Dim strCrit As String
    
              If IsDate(Me.cbxStart) Then
              strCrit = strCrit & "([OfferDate] >= #" & Format(Me.cbxStart, "mm/dd/yyyy") & "#) AND "
              End If
    
              If IsDate(Me.cbxend) Then
              strCrit = strCrit & "([OfferDate] <= #" & Format(Me.cbxend, "mm/dd/yyyy") & "#) AND "
              End If
    
              If strCrit > "" Then
              strCrit = Left(strCrit, Len(strCrit) - 5)
              DoCmd.OpenForm "searchf2", acNormal, , strCrit
              DoCmd.Close acForm, "searchs"
              End If

  6. #6
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Mike's code allows filter if only one date value is provided. The last If only opens form if there is criteria but if you want to open anyway, move OpenForm and Close lines outside the If. Then the If will just remove trailing AND if there was criteria provided.


    Review http://allenbrowne.com/ser-62.html
    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.

  7. #7
    deepaksharma is offline Competent Performer
    Windows 7 32bit Access 2016
    Join Date
    Jul 2023
    Location
    india
    Posts
    389
    thank you June and Mike.

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

Similar Threads

  1. Vb Coding Help
    By GarageConcepts in forum Access
    Replies: 1
    Last Post: 03-10-2016, 05:05 PM
  2. VBA Coding Help please
    By cfobare79 in forum Programming
    Replies: 6
    Last Post: 12-07-2014, 07:54 PM
  3. Coding for Sum in vba
    By glen in forum Programming
    Replies: 14
    Last Post: 12-20-2012, 05:10 PM
  4. Please help with VB coding
    By winterh in forum Import/Export Data
    Replies: 11
    Last Post: 03-19-2012, 06:05 PM
  5. Need help in VBA coding
    By Kcgp in forum Programming
    Replies: 6
    Last Post: 02-01-2012, 11:22 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