By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
426,122 Members | 927 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 426,122 IT Pros & Developers. It's quick & easy.

SQL and Access 2000

P: n/a
Hello,

I would like to Execute this Select Statement...

SELECT MAX(VisitorID) FROM Visitors.

Is there any way to store the result directly into a VB variable??

lngVisitorID = ???

Thanks!!!
Nov 12 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
You mean like this?
lngVisitorID=DMax("VisitorID","Visitors")

HTH
- Turtle

"Gordo" <gm****@yahoo.com> wrote in message
news:wQ*********************@news1.calgary.shaw.ca ...
Hello,

I would like to Execute this Select Statement...

SELECT MAX(VisitorID) FROM Visitors.

Is there any way to store the result directly into a VB variable??

lngVisitorID = ???

Thanks!!!

Nov 12 '05 #2

P: n/a
"MacDermott" <ma********@mindspring.com> wrote in message news:<Jw*******************@newsread2.news.atl.ear thlink.net>...
You mean like this?
lngVisitorID=DMax("VisitorID","Visitors")

HTH
- Turtle

"Gordo" <gm****@yahoo.com> wrote in message
news:wQ*********************@news1.calgary.shaw.ca ...
Hello,

I would like to Execute this Select Statement...

SELECT MAX(VisitorID) FROM Visitors.

Is there any way to store the result directly into a VB variable??

lngVisitorID = ???

Thanks!!!

Hi,

dim dbs as database
dim rst as recordset

set dbs = currentdb
set rst = dbs.openrecordset("SELECT MAX(VisitorID) AS M FROM Visitors")

if rst.recordcount >0 then
lngVisitorID = rst!M
else
lngVisitorID = 0 'or something else
end if

rst.close
dbs.close

Hope this helps (maybe not the best, but a working solution)

Gr. T


Nov 12 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.