Basic VBA task

Chose.cz

Registered User.
Local time
Today, 17:33
Joined
Aug 8, 2006
Messages
12
Hello,

I'm new to VBA and i need some help with this.

I want VBA to scan a certain table column and insert the highest value it finds there into a variable.

How do I do that?
Any help would be greatly appr.ed
 
U can use ADODB also

'''''It is a little lengthy, But the concept will benefit you in future coding


Dim strSQL As String
Dim MyValue As DataType 'Replace the proper datatype of field
Dim rs As ADODB.Recordset, Cn As ADODB.Connection
Set rs = New ADODB.Recordset
Set Cn = New ADODB.Connection
Set Cn = CurrentProject.Connection
strSQL = "SELECT tableName.ColumnName FROM tableName ORDER BY tableName.ColumnName DESC"
rs.Open strSQL, Cn, adOpenStatic, adLockReadOnly
MyValue = rs!ColumnName
rs.Close
Set rs = Nothing

''' Now ' MyValue ' is your required value. Use it anywhere in the procedure
 
Last edited:

Users who are viewing this thread

Back
Top Bottom