?
Solved

Setting Date DafaultValue on a form in MS Access

Posted on 2012-03-29
6
Medium Priority
?
322 Views
Last Modified: 2012-05-29
I have a form that pops up when a command button is pressed. The calling form has values I'd like the called form to initiate as Default Values, ie Text1.DefaultValue = Forms!Mainform!MainformValue.

All this seems fine EXCEPT for date values. I have two bound date fields  on the popped form and I'm trying to populate them with dates on the calling form. But all I get is a time format, 12:00:00 AM. There's no formatting  on the called form text box.

I've tried the code to set the date values in the On Open, On Current and On Activate Events. None of them work.

I even try to just set the default value to Date(). Even that didn't work.

No problems with references.


There's no default value in the table. The Text Box doesn't have a default value, till I set it.

I'm not sure what's going on.

Any help would be greatly appreciated.

Thanks,
E
0
Comment
Question by:eantar
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 40

Expert Comment

by:als315
ID: 37783217
0
 
LVL 48

Expert Comment

by:Dale Fye
ID: 37783226
I would generally use the Current event with code similar to:

Private Sub Form_Current

    me.PopupControl1 = cdate(forms!mainform.control1)
    me.popupcontrol2 = cdate(forms!mainform.control2)

End sub

What have you tried.  It might be easier to fix what you have tried than for us to guess on your form and control names.
0
 
LVL 20

Expert Comment

by:clarkscott
ID: 37783243
You could set these values on the OPEN FORM event.

Me.txtDate1 = Date()

or Me.txtDate1 = "1/1/2012"

Scott C
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 5

Accepted Solution

by:
eantar earned 0 total points
ID: 37783616
Hi friends,

I finally got it to work by saving the date values from the calling form into a non visible field and setting the DefaultValue of my visible field to the value of my non visible field.

Anyone have a clue as to why that worked? Why the other way didn't?

Just curious.

E
0
 
LVL 29

Expert Comment

by:IrogSinta
ID: 37785617
I'm wondering if it would work if you put it on the OnLoad event.  I'm not sure what kind of control you're using but I remember once using an ActiveX date control where the default date could only be set on the OnLoad event and not OnOpen.
0
 
LVL 5

Author Closing Comment

by:eantar
ID: 38021302
I resolved this myself
0

Featured Post

Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
We live in a world of interfaces like the one in the title picture. VBA also allows to use interfaces which offers a lot of possibilities. This article describes how to use interfaces in VBA and how to work around their bugs.
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…

718 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question