473,503 Members | 972 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Get the max value from database and display it in text box using the variable

17 New Member
Friends,

I want to get and display the Max value from database records. I used some codes. It displays the error message 'NULL"
how to rectify this.

Dim CheNo As Integer
Dim rsCheNo As New ADODB.Recordset
rsCheNo.Open "SELECT max(CHEMICALS.ChemicalCode) FROM CHEMICALS", CN, adOpenDynamic, adLockOptimistic

If rsCheNo.RecordCount <> 0 Then
Do While Not rsCheNo.EOF
CheNo = rsCheNo.Fields(0)
rsCheNo.MoveNext
Loop
End If

rsCheNo.Close
CheNo = CheNo + 1
Text1 = CheNo

Thanks,
Suresh
Jun 9 '07 #1
1 8558
pureenhanoi
175 New Member
Expand|Select|Wrap|Line Numbers
  1. Dim CheNo As Integer
  2. Dim rsCheNo As New ADODB.Recordset
  3. rsCheNo.Open "SELECT max(CHEMICALS.ChemicalCode) AS maxOfChCode FROM CHEMICALS", CN, adOpenDynamic, adLockOptimistic
  4. If rsCheNo.RecordCount <> 0 Then
  5.         CheNo = rsCheNo.Fields("maxOfChCode")
  6.         CheNo = CheNo + 1
  7.         Text1 = CheNo
  8. End If
  9. rsCheNo.Close
  10.  
Just have only one Max value is selected. so do not need using While ... Loop
Jun 9 '07 #2

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

Similar topics

3
11229
by: Joe Christl | last post by:
I was wondering - is there some part of sql that can display text? I wanted to add simple instruictions to the beginning of an sql script so the user understands what they're entering into the...
13
9585
by: Stumped and Confused | last post by:
Hello, I really, really, need some help here - I've spent hours trying to find a solution. In a nutshell, I'm trying to have a user input a value in form's textfield. The value should then be...
19
6854
by: dmiller23462 | last post by:
Hi guys....I have absolutely NO IDEA what I'm doing with Javascript but my end result is I need two text boxes to stay hidden until a particular option is selected....I've cobbled together the...
2
2777
by: eddie wang | last post by:
Hi, I am making changes to an Access application that was written by a previous coworker. All I am tring to do is to get the text from a text box called txtDate, and assign it to a string...
3
2110
by: MS | last post by:
What's the best way to "store" and display a value in a text box that changes from day to day. An example of this would be where the name of the user is manually typed in after using the datbase,...
0
1697
by: yalanue | last post by:
I want to create a combobox with its displaymember populated from a datatable. But once I get it run, the default display member in the combobox is always the first row of the displaymember list....
3
1774
by: swinster | last post by:
Hi all, I have not touched access for a very long time and am attempting to help my nephew with his Video Rental Database. This is a simple three-table relationship database comprising a Video...
1
3764
by: Java Kumar | last post by:
Hi Pals, I need your help regarding following problem.Im working in MVC model application which has jsp, servlet,and bean file. By the flow of application , I have to display datas in jsp page...
3
1672
by: WebNewbie | last post by:
Hi, please help I've been wrestling with this for a very long time and its not working. I'm trying to display text files from a database when someone selects one or more list items of my listbox. The...
2
7572
by: rameshgohil | last post by:
I am using grid view and a button column in it using <itemTemplate> but I am not able to rerive cell value of a selected row from grid view. I have tried the following to methods in Row_command...
0
7203
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7089
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7282
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7339
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6995
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7463
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5581
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
3157
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
389
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.