Results 1 to 6 of 6
  1. #1
    Akchayan is offline Competent Performer
    Windows 7 64bit Access 2016
    Join Date
    Aug 2022
    Posts
    102

    Get the maximum value of a table column in a certain range

    Hello all,


    I have a form that is connected to a table.
    Table name: "tblCustomers


    Form name: "foCustomerCapture
    In the table "tblCustomers" I have a column called customer number. I have divided this customer number into 3 different categories
    Category 1 are numbers from 100-199
    Category 2 are numbers from 200-299
    Category 3 are numbers from 300-399


    And I want the maximum value of the categories to be displayed on the right side of my form.
    It should look something like this:
    Click image for larger version. 

Name:	Unbenannt.png 
Views:	11 
Size:	8.4 KB 
ID:	49334


    I have imagined that the content of the control could look like this for category 1, for example: customer_number<200, MAX
    Just from the logic, so the code is not right but that is the goal that should come out in the end.


    I haven't found a solution yet. Do you have an idea what I should enter?

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,527
    set the source of the text boxes , or assign at form load:

    txtBox1 = Dmax([field2Return], "table" ,"[Category 1] between 100 and 199")
    txtBox2 = Dmax([field2Return], "table" ,"[Category 2] between 200 and 299")
    txtBox3 = Dmax([field2Return], "table" ,"[Category 3] between 300 and 399")

  3. #3
    Akchayan is offline Competent Performer
    Windows 7 64bit Access 2016
    Join Date
    Aug 2022
    Posts
    102
    Quote Originally Posted by ranman256 View Post
    set the source of the text boxes , or assign at form load:

    txtBox1 = Dmax([field2Return], "table" ,"[Category 1] between 100 and 199")
    txtBox2 = Dmax([field2Return], "table" ,"[Category 2] between 200 and 299")
    txtBox3 = Dmax([field2Return], "table" ,"[Category 3] between 300 and 399")
    I have entered this here in the Control Content field:
    Click image for larger version. 

Name:	Screenshot 2022-12-19 183533.png 
Views:	10 
Size:	4.0 KB 
ID:	49336
    but it didnt work, do you know what i did wrong?

  4. #4
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,123
    I don't think you have a category set anywhere so try this:
    txtBox1 = Dmax("Kundennummer", "tblKunde" ,"[Kundennummer] < 199")

    Cheers,
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

  5. #5
    Akchayan is offline Competent Performer
    Windows 7 64bit Access 2016
    Join Date
    Aug 2022
    Posts
    102
    Quote Originally Posted by Gicu View Post
    I don't think you have a category set anywhere so try this:
    txtBox1 = Dmax("Kundennummer", "tblKunde" ,"[Kundennummer] < 199")


    Cheers,
    Thank you very much! It worked.

  6. #6
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,123

    You're very welcome!
    Cheers,
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

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

Similar Threads

  1. Maximum table length
    By Western_Neil in forum Database Design
    Replies: 8
    Last Post: 05-24-2019, 02:11 PM
  2. Replies: 1
    Last Post: 02-05-2015, 08:12 AM
  3. Replies: 6
    Last Post: 10-09-2014, 12:41 PM
  4. Maximum values from a date range
    By FatLane in forum Queries
    Replies: 3
    Last Post: 07-10-2012, 05:09 PM
  5. sales DB selecting column and column range
    By pher77 in forum Queries
    Replies: 3
    Last Post: 06-11-2011, 04:04 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