Go Back   Access World Forums > Microsoft Access Discussion > Forms

 
Reply
 
Thread Tools Rate Thread Display Modes
Old 07-25-2013, 03:19 PM   #1
dark11984
Newly Registered User
 
Join Date: Mar 2008
Location: Sydney, Australia
Posts: 126
Thanks: 2
Thanked 0 Times in 0 Posts
dark11984 is on a distinguished road
Default value for subform text box

Hi Guys,
I have a mainform and a datahseet subform.

Mainform = FrmProj_ProjectEntry
Subform = FrmProj_ProjectEntry_Sub1

On my mainform I have a text box (FrmProj_ProjectEntry.txtDueDt) where I enter an expected date.
On my subform I also have a textbox (FrmProj_ProjectEntry_Sub1.txtDueDt) for entering an expected date.

I would like the entered date on the mainform to become the default expected date on the subform for new records only. Once records are created the expected date can then be changed for each record.

How would I achieve this on an after update event on FrmProj_ProjectEntry.txtDueDt?

Thanks

dark11984 is offline   Reply With Quote
Old 07-25-2013, 03:33 PM   #2
MarkK
Super Moderator
 
MarkK's Avatar
 
Join Date: Mar 2004
Location: Vancouver BC
Posts: 7,761
Thanks: 10
Thanked 1,290 Times in 1,227 Posts
MarkK is a name known to all MarkK is a name known to all MarkK is a name known to all MarkK is a name known to all MarkK is a name known to all MarkK is a name known to all
Set the DefaultValue property of the TextBox control. To reference that control from the mainform, on the subform, use syntax like . . .
Code:
dim tb as textbox
set tb = Me.SubformControlName.Form.TargetTextboxControlName
tb.defaultvalue = <some value>
__________________
formerly known as lagbolt | Windows 10 | Access 2010 | Visual Studio 2013 | "Institutions have a vested interest in perpetuating the problems to which they are the solution." - Clay Shirky
MarkK is offline   Reply With Quote
Old 07-25-2013, 03:45 PM   #3
dark11984
Newly Registered User
 
Join Date: Mar 2008
Location: Sydney, Australia
Posts: 126
Thanks: 2
Thanked 0 Times in 0 Posts
dark11984 is on a distinguished road
Re: Default value for subform text box

Compile Error:
Method or data member not found

dark11984 is offline   Reply With Quote
Old 07-25-2013, 04:07 PM   #4
MarkK
Super Moderator
 
MarkK's Avatar
 
Join Date: Mar 2004
Location: Vancouver BC
Posts: 7,761
Thanks: 10
Thanked 1,290 Times in 1,227 Posts
MarkK is a name known to all MarkK is a name known to all MarkK is a name known to all MarkK is a name known to all MarkK is a name known to all MarkK is a name known to all
That error is in respect to some code somewhere.
__________________
formerly known as lagbolt | Windows 10 | Access 2010 | Visual Studio 2013 | "Institutions have a vested interest in perpetuating the problems to which they are the solution." - Clay Shirky
MarkK is offline   Reply With Quote
Old 07-25-2013, 04:08 PM   #5
JamesM
Newly Registered User
 
Join Date: Jul 2013
Location: Australia
Posts: 16
Thanks: 8
Thanked 3 Times in 3 Posts
JamesM is on a distinguished road
Re: Default value for subform text box

Hi,

I think this is what you are after

in form FrmProj_ProjectEntry_Sub1 on event AfterUpdate for field txtDueDt

Code:
 
Private Sub txtDue_AfterUpdate()
     Me.txtDueDt.Value = Forms("Main_Form").txtDueDT.Value
End Sub
James

JamesM is offline   Reply With Quote
Reply

Tags
after update , default value , subform mainform

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How Do I put Text Boxes on Subform ( not Datasheet view default ) ? liamfitz Forms 1 06-07-2012 12:52 PM
Display default text if no text is entered into an inputbox? KevinSlater Reports 4 09-17-2008 01:06 AM
Text As a Default Value promethian Forms 3 05-19-2008 09:49 PM
Combining text and a date value as a default value on a text box shelds Forms 2 04-18-2007 01:17 PM
Type over default text in text box livvie Forms 2 11-09-2004 08:37 AM




All times are GMT -8. The time now is 01:55 PM.


Microsoft Access Help
General
Tables
Queries
Forms
Reports
Macros
Modules & VBA
Theory & Practice
Access FAQs
Code Repository
Sample Databases
Video Tutorials

Featured Forum post


Sponsored Links


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
(c) copyright 2017 Access World