Dlookup or dmax for previous record

G

Guest

Hello,

I'm trying to create a expression for a cmd button that will fill in fields
from the previous record. Looking on the groups I found some examples, but
I'm unable to get them to work. Here is an example of what I have tried.

DLookUp("[TestTitle]","TafInfoTbl","[ID]=Forms![LoginFrm]![ID]-1")
When I enter this I get "expected =" error

I was also reading that using dmax was better but was unable to to get that
working.

Any help would be great
Thank You
David
 
G

Guest

Thank you for your help so far.

For whatever reason I still get Compile Error: = Any ideal?
Thank you Again
David


Ofer said:
What is the type of the field [TestTitle]?
How many users working on the application? if more then one it can cause
duplicates.
If no records are return using the DMax, the Nz will replace the field with 0

Try
If the Id fieldType is number
Nz(DMax("[TestTitle]","TafInfoTbl","[ID]= " & Forms![LoginFrm]![ID]) ,0)

If the Id fieldType is text
Nz(DMax("[TestTitle]","TafInfoTbl","[ID]= '" & Forms![LoginFrm]![ID] & "'")
,0)
===================
To use Dlookup just replace the Dmax with DLookup

--
\\// Live Long and Prosper \\//
BS"D


David said:
Hello,

I'm trying to create a expression for a cmd button that will fill in fields
from the previous record. Looking on the groups I found some examples, but
I'm unable to get them to work. Here is an example of what I have tried.

DLookUp("[TestTitle]","TafInfoTbl","[ID]=Forms![LoginFrm]![ID]-1")
When I enter this I get "expected =" error

I was also reading that using dmax was better but was unable to to get that
working.

Any help would be great
Thank You
David
 
G

Guest

Can you post what you have, and what is the error?

--
\\// Live Long and Prosper \\//
BS"D


David said:
Thank you for your help so far.

For whatever reason I still get Compile Error: = Any ideal?
Thank you Again
David


Ofer said:
What is the type of the field [TestTitle]?
How many users working on the application? if more then one it can cause
duplicates.
If no records are return using the DMax, the Nz will replace the field with 0

Try
If the Id fieldType is number
Nz(DMax("[TestTitle]","TafInfoTbl","[ID]= " & Forms![LoginFrm]![ID]) ,0)

If the Id fieldType is text
Nz(DMax("[TestTitle]","TafInfoTbl","[ID]= '" & Forms![LoginFrm]![ID] & "'")
,0)
===================
To use Dlookup just replace the Dmax with DLookup

--
\\// Live Long and Prosper \\//
BS"D


David said:
Hello,

I'm trying to create a expression for a cmd button that will fill in fields
from the previous record. Looking on the groups I found some examples, but
I'm unable to get them to work. Here is an example of what I have tried.

DLookUp("[TestTitle]","TafInfoTbl","[ID]=Forms![LoginFrm]![ID]-1")
When I enter this I get "expected =" error

I was also reading that using dmax was better but was unable to to get that
working.

Any help would be great
Thank You
David
 

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

Top