Access 2007 VBA recordset (1 Viewer)

Crilen007

Uhm, Title... *shrug*
Local time
Today, 08:59
Joined
Jun 13, 2003
Messages
531
Whats the new proper way to do recordsets in VBA for Access 2007?


Any examples would be great, thanks.
 

boblarson

Smeghead
Local time
Today, 08:59
Joined
Jan 12, 2001
Messages
32,059
Same way as in previous versions, why do you ask? You can use DAO or ADO (for ACCDB files, DAO is the default).
 

Crilen007

Uhm, Title... *shrug*
Local time
Today, 08:59
Joined
Jun 13, 2003
Messages
531
Hmm...


There a way to select a record set using an SQL statement instead of the query name?
 

boblarson

Smeghead
Local time
Today, 08:59
Joined
Jan 12, 2001
Messages
32,059
Yep, you can set the recordset in the On Load event:

Me.Recordset = "SELECT whatever FROM whateverTable WHERE WhateverField = WhateverValue"

etc.
 

Crilen007

Uhm, Title... *shrug*
Local time
Today, 08:59
Joined
Jun 13, 2003
Messages
531
Well...


What I'm trying to do is calculate the time difference between records in a table using VBA and cycling records.

So I was hoping to select the records using SQL so I can choose what day and person it should be etc... It's been a while since I've had to use access lol, I would normally use PHP to do something like this.
 

Crilen007

Uhm, Title... *shrug*
Local time
Today, 08:59
Joined
Jun 13, 2003
Messages
531
Well I guess I can use SQL instead of the Query Name, I love VBA sometimes lol
 

boblarson

Smeghead
Local time
Today, 08:59
Joined
Jan 12, 2001
Messages
32,059
I thought you wanted a SQL Statement instead of the query name. You can also use

Me.Recordsource = "NameOfSavedQuery"

that will work too.
 

Users who are viewing this thread

Top Bottom