Default.value and/or DLookup? (1 Viewer)

leecey5225

New member
Local time
Today, 09:07
Joined
Feb 22, 2017
Messages
2
Hi,
I am trying to default a set of values into the header records of a subform based on values passed from the previous mainform. I have tried a large number of variations on a theme, but this is what I have as the latest. All I get in the form is #NAME? Any ideas please - I am new to VBA!

=[Forms]![CprLessonsLearned]![LL_CPRID].[DefaultValue]=DLookUp([CPR.CPRID],[CPR],"[LL_CPRID] = " & [Forms]![MainForm]![Detail]![CprId])

CprLessonsLearned is the subform, with LL_CPRID the name of the form field. I need this to always default to the CprId in the Mainform so it doesn't get wiped everytime I create a new record (which is why I'm doing this in the first place)
 

Minty

AWF VIP
Local time
Today, 09:07
Joined
Jul 26, 2013
Messages
10,366
If you have set the form / sub form Master child properties correctly this should be automatic, assuming that LL_CPRID is the linking field?

If it's not the Foreign key you are probably storing it needlessly as it can be pulled from the parent header anyway.
 

leecey5225

New member
Local time
Today, 09:07
Joined
Feb 22, 2017
Messages
2
Hi,

It does default as soon as I open the form (as I have set this in the Openfrm cmd), however as soon as I click 'new record' or navigate to a blank row in the detail of the form, the header details get wiped out so I cannot link any data from the detail to the header record. (I have read it is an access 2010 problem) - so I thought the way to mitigate this would be to always default the values so they will remain constant even when a new row is added?
Thanks,
Lisa
 

Users who are viewing this thread

Top Bottom