Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL Statement

Status
Not open for further replies.

thegameoflife

Programmer
Dec 5, 2001
206
US
How do you write a simple SQL statement in Access VBA?

I'm trying to select the MAX value of field YMDPAID from Table1.....

this is killing me
 
So what is wrong with this

Code:
Sub testtest()

Dim qrysql As String
Dim today As Date

today = Date

qrysql = "SELECT MAX(YMDPAID) FROM Table1"

If qrysql = today Then
    MsgBox "good"
End If

End Sub
 
Hi thegaetc

1. you define qrysql as a STRING, and you fill it with a STRING; what is in qrysql after testtest is simply the string you put in it !!!

2. I only can tell you how I would do this in Access for instance.
The Recordsource for the form is the query:
SELECT Max([Tabel1]![YMDPAID]) AS Mx FROM Tabel1

Put one textbox on the form, and it has as ControlSource:
[Mx]

When you open that form, the maximumdate of Table1 appears in that textbox, etc.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top