Need Help on Various Small Issues

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Tyler1394
    New Member
    • Jul 2016
    • 18

    #1

    Need Help on Various Small Issues

    I'll be brief:

    Issue 1:
    I have a combobox search box that allows me to choose from a drop down menu of options. When one item XX is selected, it displays only the records that contain such item XX. however if I clear the search box, the records still show a reduced value of records only containing XX. I would like to return to all records when I clear the search box menu. Any ideas?

    Issue 2:
    On my form,
    I have the undo button to remove the previous steps taken. However, I would like a simple 'clear all button'
    Creating a button that, when clicked, sets all combo boxes to NULL doesn't seem to work.
    I get a runtime error - you must enter a value in the "XXX" field.

    Any ideas?
  • Cbold
    New Member
    • Aug 2016
    • 6

    #2
    Have you tried REFRESH in the on change property of the combo box?

    Comment

    • jforbes
      Recognized Expert Top Contributor
      • Aug 2014
      • 1107

      #3
      What is the code for your ComboBox after update event? My guess is that it will only apply a Filter when something is selected in the ComboBox, but doesn't clear the Filter when nothing is selected. Or it may be missing the refresh like Cbold has suggested.

      What are you attempting to accomplish with your clear all button that an Undo won't accomplish? And by Undo, do you mean Form.Undo Method (Access): Me.Undo

      If not, could you explain the situation more? Are you on a New Record when you are doing this? Are you on an Existing Record. Are you using Bound or Unbound fields? What code have you attempted?

      Comment

      • Tyler1394
        New Member
        • Jul 2016
        • 18

        #4
        Hey guys thanks for the responses.

        With Regard to the search box:



        Private Sub cboshiftlookup_ AfterUpdate()
        Dim myLookup As String
        myLookup = " Select * from MainTableT where ([Shift] = " & Me.cboshiftlook up & ")"
        Me.MainTableT_s ubform.Form.Rec ordSource = myLookup
        Me.MainTableT_s ubform.Form.Req uery
        End Sub

        I have not tried REFRESH. I'm not great with programming this has been a work in progress but i'll see what happens.



        With respect to the undo.
        I've been using the undo record using the embedded macro. I guess the issue is if they input a value from a combo box then change it, the undo will bring them back to the first input, and I would like it to be cleared completed to "start from scratch" rather than undo to the previous input.


        I forgot to mention:
        through my form, the user will always have access to all records and only when they hit 'add record' will they be brought to a new empty form for a new record. I was wondering how I could set up either code or perhaps another record so that the users are only able to input data on new records, with the previous records being locked unless an 'administrator' goes in an changes it. This can be done through having the previous records visible or invisible to the user I don't care I just don't want the user to be able to change the previous records.

        Comment

        • jforbes
          Recognized Expert Top Contributor
          • Aug 2014
          • 1107

          #5
          I think you will want to do something like the following for your AfterUpdate of the ComboBox. There are other ways of doing this, this is just one way that is similar to what you were already doing:
          Code:
          Private Sub cboshiftlookup_AfterUpdate()
              Dim myLookup As String
              Dim lShift As Long
              myLookup = " Select * from MainTableT "
              lShift = Nz(Me.cboshiftlookup, 0)
              If lShift > 0  Then
                  myLookup = myLookup & " where ([Shift] = " & lShift & ")"
              End If
              Me.MainTableT_subform.Form.RecordSource = myLookup
              Me.MainTableT_subform.Form.Requery
          End Sub
          The idea is to show all records and then apply a where clause only if the users has selected something from the ComboBox.


          You might want to check out this Set all form controls to null. It would be a good starting place on how to clear out all your fields.


          I use Allen Browne's approach when Locking bound controls. It may seem complex at first, but it's actually pretty easy to get going and use. Pay close attention to bullet point #6, as this is pretty key to exclude controls from being locked. By locking the controls, you can open the Form in edit mode and then control through code whether or not the user can make edits.

          For future reference, we try to limit a thread to only one question. It makes it easier to answer and for people to follow along when they have similar questions.

          Comment

          • NeoPa
            Recognized Expert Moderator MVP
            • Oct 2006
            • 32669

            #6
            Originally posted by Tyler
            Tyler:
            Need Help on Various Small Issues
            In that case you need to ask a separate question for each issue - as per the site rules (that you're probably not familiar with yet).

            The reason for that rule is well illustrated in this thread which is a right royal pain to try to follow as well as to help with.

            It's too late to sort this one out as members have responded already on multiple fronts. Please remember in future though.

            Comment

            Working...