Results 1 to 4 of 4
  1. #1
    gint32 is offline Competent Performer
    Windows 7 64bit Access 2013
    Join Date
    Jan 2015
    Location
    Australia
    Posts
    116

    Can't find the VBA code behind downloaded example MDB

    Hi Everyone,

    I am trying to rework some code within a Db that I found during my searches at https://access-programmers.co.uk/for...d.php?t=188663

    I have been looking at the code behind and although I am not the brightest, I think I understand most of what to do to with it to make it suit my needs.

    My issue is that i am stuck at one part, I just can't seem to figure out how the code works with the radio buttons named (Option39,41 etc etc) labelled cork , stelvin on the main form, can anyone explain to me the principle of how these work on change event, please see the sample DB attached for the info.

    The form has a textbox the has an onchange event with this code :

    Code:
    Private Sub SearchFor_Change()
    
    'Create a string (text) variable
        Dim vSearchString As String
    
    'Populate the string variable with the text entered in the Text Box SearchFor
        vSearchString = SearchFor.Text
    
    'Pass the value contained in the string variable to the hidden text box SrchText,
    'that is used as the sear4ch criteria for the Query QRY_SearchAll
        SrchText.Value = vSearchString
    
    'Requery the List Box to show the latest results for the text entered in Text Box SearchFor
        Me.SearchResults.Requery
    
    
    'Tests for a trailing space and exits the sub routine at this point
    'so as to preserve the trailing space, which would be lost if focus was shifted from Text Box SearchFor
        If Len(Me.SrchText) <> 0 And InStr(Len(SrchText), SrchText, " ", vbTextCompare) Then
            Exit Sub
        End If
    
    'Set the focus on the first item in the list box
        Me.SearchResults = Me.SearchResults.ItemData(1)
        Me.SearchResults.SetFocus
    
    'Requery the form to refresh the content of any unbound text box that might be feeding off the record source of  the List Box
        DoCmd.Requery
    
    'Returns the cursor to the the end of the text in Text Box SearchFor
        Me.SearchFor.SetFocus
    
        If Not IsNull(Len(Me.SearchFor)) Then
            Me.SearchFor.SelStart = Len(Me.SearchFor)
        End If
    
    
    End Sub
    Thanks in advance to anyone who can explain in simple terms
    Attached Files Attached Files

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,822
    Code is behind the OptionGroup frames. Not seeing the frame values used anywhere but somehow clicking radio button does cause filtering of the listbox items.

    I set breakpoint in the Frame procedure and see the value of Me.SearchResults.ItemData(1) change according to whichever radio button is pressed. Why do Stelvin, Still, Rose all retrieve value 139 for Angove's Nine Vines? Clicking Cork retrieves 349 for Campirosa. Etc for the other buttons.

    Okay, found references to the Frames in QRY_SearchAll as dynamic parameters. That's all there is to it. Mystery solved. I never use dynamic parameterized queries, so escaped me for a while.
    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
    gint32 is offline Competent Performer
    Windows 7 64bit Access 2013
    Join Date
    Jan 2015
    Location
    Australia
    Posts
    116
    Re-I never use dynamic parameterized queries...neither have I,,seems unconventional and still cant get my head around the use of whats is a dynamic parameterized query, so still stupt is there an easier way to acheive the same, as it's still way over my head to understand(as there is no event action) so I am lost as too what who or how its triggered

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,822
    The event action is the button click which runs Requery command. The form's RecordSource is requeried/refreshed and because the values of the referenced parameters have changed, the set of records will change accordingly.
    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.

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

Similar Threads

  1. need help with reading code in downloaded file
    By ringnalda506 in forum Access
    Replies: 2
    Last Post: 12-03-2013, 11:32 AM
  2. Replies: 5
    Last Post: 10-28-2012, 03:26 AM
  3. Find multiple words within Code
    By Mooo0 in forum Programming
    Replies: 1
    Last Post: 03-07-2012, 10:54 PM
  4. Replies: 2
    Last Post: 03-02-2012, 09:17 AM
  5. Find primary key name by code
    By MichaelS in forum Access
    Replies: 2
    Last Post: 09-22-2011, 07:09 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