Results 1 to 8 of 8
  1. #1
    huk250 is offline Novice
    Windows 11 Access 2021
    Join Date
    Apr 2024
    Posts
    5

    Using dmax on one column and then placing action on respectivly record next to it

    A good afternoon,

    I have a table CDNUM with the following columns

    ID Random
    1 50
    4 60
    6 30
    3 20
    5 20
    2 10

    I want in a form in Visual Basic a event procedure so that he looks in the column of ID for the highest value and then in the Column Random (in the corresponding record) add 5
    when I do this



    [Random] = DMAX ("RANDOM", "CDNUM") + 5

    then it will look in the second column for the highest part and add 5 : so here it will be 65

    I want that the highest part in column ID and then that it gives me 35
    kindest regards

  2. #2
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,945
    In my world 6 is higher than 4, so I would expect 35 ?

    So your ctriteria would be a DMax() of ID not of Random?
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  3. #3
    huk250 is offline Novice
    Windows 11 Access 2021
    Join Date
    Apr 2024
    Posts
    5
    this is correct this was an example
    I want the dmax of column ID and count up the Random Column +5

  4. #4
    huk250 is offline Novice
    Windows 11 Access 2021
    Join Date
    Apr 2024
    Posts
    5
    I want to look up the Dmax in column of the ID but I don't want the ID number, I want the corresponding record in the column of Random so that I can add 5

  5. #5
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,945
    So as I mentioned use Dmax() for the ID as criteria for the Dlookup() for Random.

    BTW 'I would like' is much more polite than 'I want'
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  6. #6
    orange's Avatar
    orange is online now Moderator
    Windows 10 Office 365
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726
    Try this SQL in your event

    Code:
    select random +5  as newRandom from cdnum
    where id =(select top 1 dmax("id","CDNUM") from cdnum )
    newRandom
    35

  7. #7
    huk250 is offline Novice
    Windows 11 Access 2021
    Join Date
    Apr 2024
    Posts
    5
    A good afternoon, I made the following line in Visual Basic but this doesn't give me the correct result

    [RANDOM] = DLookup("RANDOM", "CDNUM", DMax("ID", "CDNUM")) + 5

    Can you help me to resolve my problem
    Kindest regards

  8. #8
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,945
    You need to say what field is equal to the criteria supplied?
    How else is Access meant to guess?

    If you do not know the syntax then Google it.
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

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

Similar Threads

  1. DMAX previous record
    By oldmanbumper in forum Access
    Replies: 16
    Last Post: 08-16-2022, 11:55 AM
  2. Replies: 7
    Last Post: 08-31-2018, 04:44 PM
  3. DMAx Question for Report - DMax <= Dtae
    By crimedog in forum Access
    Replies: 8
    Last Post: 12-29-2014, 09:31 PM
  4. Replies: 2
    Last Post: 11-08-2012, 05:22 AM
  5. Replies: 6
    Last Post: 07-24-2012, 03:02 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