Setting DefaultValue in subform

User avatar
agibsonsw
SilverLounger
Posts: 2403
Joined: 05 Feb 2010, 22:21
Location: London ENGLAND

Setting DefaultValue in subform

Post by agibsonsw »

Hello. Access 2010.

I have main form for Events which opens a second form linked via EventID. This second form contains a subform. I want to set a DefaultValue for a field in the subform. It is actually for the value just in an adjacent field (of the subform).

I tried using OnCurrent for the subform, setting

Me.Text1.DefaultValue = """" & Me.TheOtherOne & """""

but no joy. Thanks, Andy
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.

User avatar
HansV
Administrator
Posts: 78545
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Setting DefaultValue in subform

Post by HansV »

That's one " too many at the end.
If the values are numbers, you can omit the """"
Best wishes,
Hans

User avatar
agibsonsw
SilverLounger
Posts: 2403
Joined: 05 Feb 2010, 22:21
Location: London ENGLAND

Re: Setting DefaultValue in subform

Post by agibsonsw »

Hello and thanks @Hans.

I didn't have the extra quote in the original but it turns out it wasn't the default value anyway, Doh! The records were created on the first form.

Just chatting..
The value I needed for the default should have been read after joining four tables, but it is difficult when you have little time and someone sitting at your shoulder :scratch:. To get it working I cheated: I used the AfterUpdate of a combobox to read two ID values on the form, store them in VBA variables and construct a DLOOKUP to extract the single value I needed. I always feel that this is cheating but, pragmatically, it works and is very straight-forward.

Regards, Andy.
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.