473,383 Members | 1,737 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

Trying to find the biggst value in a table

Hi,

Ive got a Product table that has a productID.
This is incremented insdie the access table itself.
What im trying to do is find the biggest number in the table and output all the information in that row.

Now the biggest number keeps changing when a new product is entered. ie.
Product ID = 34 contains plugs.
if a new product is entered it will become
product id = 35 contains screws.

So how can i write a code that finds the largest by just looking into the biggest number?
Dec 14 '11 #1
2 1395
sierra7
446 Expert 256MB
Hi
One way is to create a query selecting each of the fields from your Product table, then set Order By to ProductID Descending. Create a Form based on this query and the first item to be displayed will be the last one added. No code needed.

Alternatively you could use the DMax() function to find the largest ProductID. But what do you mean by 'output all the information in that row'? To where? a pop-up message window, a form or a report?

We need more info to take this further.
S7
Dec 14 '11 #2
NeoPa
32,556 Expert Mod 16PB
I'm going to assume for now that you are looking for a query that returns the data you requested. If you need other information then, as S7 says, you need to provide more information in the question.

Expand|Select|Wrap|Line Numbers
  1. SELECT *
  2. FROM   [Product]
  3. WHERE  ([ProductID] = SELECT Max([ProductID])
  4.                       FROM   [Product])
This uses a subquery to determine the max value, which is similar to using DMax() but where DMax() is a function the subquery is part of the SQL itself so can work more efficiently. Domain Aggregate functions like DMax() are of most use when used from within VBA code, although they certainly can be used within SQL too if required.
Dec 14 '11 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

10
by: mike | last post by:
regards: Where to find tag mapping-table of HTML translated to XHTML1.0 Any positive suggestion is welcome. thank you May goodness be with you all
2
by: Mark | last post by:
Hello - From an Access VBA module, I'm trying to pass a Table to a VB.Net class. I'm getting the following error running the VBA: "Unable to cast object of type System._ComObject to type...
3
by: bikkaran | last post by:
how to find the base table of an ALIAS ? thanks
2
by: Ros | last post by:
Peeps, I need help with trying to find a value in array of arrays. Public Module myModule Private Site_Access() As Array Property Set_SA() Get Return Site_Access End Get
1
by: umeshdchaudhari | last post by:
fist I filled value of drow down and GridView control. Now we find the databound of grid view control as per drow down value at time binding. ? How we find the value of control time of binding in...
0
by: grasshopper2 | last post by:
I am trying to update a table on a sql 2000 or 2005 box ( am not sure what version its running how do I check?) I am so green I feel like kermit the frog! computer is running windows 2000,...
1
by: babyjek | last post by:
SELECT ProjectID, ProjectName, ProjectDescription, SequenceNumber, LastUpdateDate FROM Project WHERE ProjectID = @ProjectID; (The Microsoft Jet database engine cannot find the input table or...
0
by: Smish | last post by:
I have created a class library which has user defined functions for excel. One of functions need reference to current excel so as to insert value to many cell. I have given the code below showing...
6
by: warpcon | last post by:
Im trying to build a database starting with one of the templates that come with access. I took out the employee part in all the tables and forms. Now when I pull up a workorder and then try to view...
2
by: Jackson Werid | last post by:
Is it posible to use only stdio.h library to find roundup value, and find all the factor of a number I am wondering how roundup is work with using a function but not cmath library, and how to...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.