getting a record

J

Jean-Paul

Hi,

Until now, to get a specific record I wrote folliwing code:

Dim db As Database
Dim TB As Recordset
Dim SQL As String
Set db = CurrentDb()
SQL = "SELECT Setup.omschrijving, Setup.detail FROM Setup WHERE
Setup.omschrijving='gebruiker';"
Set TB = db.OpenRecordset(SQL)
MP_Setup.gebruiker = TB!detail

This works perfectly but I'm sure there must be a simpler way....

Can somebody explain a better way?
Thanks
 
A

Albert D. Kallal

Jean-Paul said:
Hi,

Until now, to get a specific record I wrote folliwing code:

Dim db As Database
Dim TB As Recordset
Dim SQL As String
Set db = CurrentDb()
SQL = "SELECT Setup.omschrijving, Setup.detail FROM Setup WHERE
Setup.omschrijving='gebruiker';"
Set TB = db.OpenRecordset(SQL)
MP_Setup.gebruiker = TB!detail

This works perfectly but I'm sure there must be a simpler way....

Can somebody explain a better way?
Thanks

you can use:

MP_Setup.gebruiker("detail","SetUp","omschriving = 'gebruiker'")

and, you could use in code

dim TB as recordSet

set tb = currentdb.OpenRecordSet("SELECT omschrijving,detail FROM
Setup WHERE Setup.omschrijving='gebruiker'")
MP_Setup.gebruiker = TB!detail

So, you really don't have to define so many variblaes here........

I suppose for ease of reading, I would dim a sql var, but that give us:

dim TB as recordSet
dim SQL as string

SQL = "SELECT detail FROM Setup WHERE omschrijving='gebruiker'"
set tb = currentdb.OpenRecordSet(SQL)
MP_Setup.gebruiker = TB!detail


So, you can pair down the amout of code you writing, but dlookup is only one
line....

= klookup("fieldName","TableName","where")
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

code goes too fast 1
next record please 6
From 2003 to2007 1
recordset "over" 2 forms 3
Editing record 2
sql and recordcount dont give same results 7
entryfield linked to selectionlist 1
in use by another 4

Top