Solved

Setting Date DafaultValue on a form in MS Access

Posted on 2012-03-29
6
320 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 47

Expert Comment

by:Dale Fye (Access MVP)
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
Technology Partners: 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

Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

Question has a verified solution.

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

It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

739 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