Results 1 to 7 of 7
  1. #1
    ahuffman24 is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    May 2019
    Posts
    99

    microsoft access error the command or action isn't available right now

    Hi,

    I am using Microsoft Access 2016. I have a table called "Customer_Order_Info_Table" and a continuous form called "Inspection_Selection_Form1" that displays all the data from the Customer_Order_Info_Table. The Inspection_Selection_Form1 is shown below:

    Click image for larger version. 

Name:	searching and sorting inspection.jpg 
Views:	13 
Size:	225.6 KB 
ID:	38481

    I am trying to add two combo boxes to the Inspection_Selection_Form1; one combo box (the Search By combo box shown in the upper right corner of the above picture) will allow the user to select a field from the Customer_Order_Info_Table to filter by, and the other combo box (the Sort combo box shown in the upper right corner of the picture) will allow the user to choose to sort the field by ascending or descending order.


    I have set up the macros for the sort box to sort by ascending or descending order (As shown in another picture below):

    Click image for larger version. 

Name:	sortcomboboxproperty.png 
Views:	13 
Size:	12.2 KB 
ID:	38482 Click image for larger version. 

Name:	Data section.png 
Views:	13 
Size:	14.0 KB 
ID:	38485 Click image for larger version. 

Name:	sort combo box macro.png 
Views:	13 
Size:	26.9 KB 
ID:	38483

    However, I am receiving this error when I try to filter and sort my form:

    Click image for larger version. 

Name:	Searching and sorting error.png 
Views:	13 
Size:	19.9 KB 
ID:	38484

    What could be causing this error?

  2. #2
    Minty is offline VIP
    Windows 10 Access 2016
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,003
    I think (and I don't use macro's so I may be out here), you appear to be trying to sort the combo boxes values, which you can't do!.

    You need to simply apply the order you want to the form not the combo. In VBA (which is way easier to follow) it would be something like (aircode untested)

    Code:
    If Me.SortCombo = "Ascending" Then 
      
           Me.OrderBy = "[YourField] Asc"
    
    Else 
    
           Me.OrderBy = "[YourField] Desc"
    
    End If
    
    Me.OrderByOn = True
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  3. #3
    ahuffman24 is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    May 2019
    Posts
    99
    Where do I go to type in that code?

  4. #4
    Minty is offline VIP
    Windows 10 Access 2016
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,003
    Click on the after update event of the combo and select Event Procedure in drop down box by the .... at the end.

    It should open the VBA editor, and should create something that looks like

    Code:
    Private Sub SortCombo_AfterUpdate()
    
    End Sub
    Put the code in between those two statements. You have just made you first VBA code programming!

    Simples
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  5. #5
    ahuffman24 is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    May 2019
    Posts
    99
    Thanks! What does "YourField" represent?

  6. #6
    Minty is offline VIP
    Windows 10 Access 2016
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,003
    Ok to break it down a bit for future reference.

    Me. This references the current form object.
    So Me.OrderBy is the sort order property the current form.

    The "[YourField] Asc" bit you need to replace by the field name you want to sort by.
    So if it was your customer name field (and get used to naming things without spaces or special characters please - you'll thank us in the long run)

    Me.OrderBy = "[Customer Name] Desc"
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  7. #7
    ahuffman24 is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    May 2019
    Posts
    99
    Thank you!

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

Similar Threads

  1. Replies: 12
    Last Post: 05-18-2017, 10:15 AM
  2. Replies: 11
    Last Post: 11-30-2015, 01:06 PM
  3. Replies: 15
    Last Post: 06-29-2015, 11:12 AM
  4. Replies: 3
    Last Post: 01-02-2015, 02:06 PM
  5. Replies: 3
    Last Post: 06-09-2012, 08:14 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