[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Date time picker value from text field

Posted on 2002-06-21
7
Medium Priority
?
337 Views
Last Modified: 2012-06-27
Hi. I am developing a time sheet application for work and i am using the dtp control to enter start time, and finish times into TextBoxes. There is a command button beside each text field which, when clicked, displays a small form with a dtp control. When the user sets and accepts a time, e.g. 04:00 PM , this value is displayed in the appropriate TextBox on the first form and the second form is unloaded.

In the event that a user reloads the dtp form to edit their time, I would like the value in the date time picker to display the value displayed in the TextBox on the first form.

I keep getting an out of Min and Max Date range error when the second form is loaded.

I would like some example code that shows me how to set a date time picker from a TextBox string.
form2.dtpControl.Value = CDate(form1.txtFinTime.Text)   just doesn't work for me.
Thanks in advance
Clive
0
Comment
Question by:clive1
7 Comments
 
LVL 2

Expert Comment

by:priya_pbk
ID: 7100145
I tried it works for me. This is what is did,

-Form1:
consists of a textBox, and a command button
code:
Private Sub Command1_Click()
Form2.Show
End Sub


--------------------------------------

In Form2:
Private Sub Form_Activate()
'MsgBox Form1.Text1
'MsgBox DTPicker1.Value
DTPicker1.Value = Form1.Text1
End Sub

---------------------------------------

I wrote this date in the text1 at runtime. ie 7/25/2002
Shows me the proper date in the Dtpicker1 what i had written in the textbox

Startup form is Form1.

Is this what you wanted.Hope this helps!

-priya
0
 
LVL 1

Expert Comment

by:harsh008_k
ID: 7100198
clive,
u want date and time or just time?
0
 
LVL 2

Expert Comment

by:priya_pbk
ID: 7100271
ok, try this. I think this is what you want.

Changes to my last code:
---------------------------------------------
-Form1:
consists of a textBox and a command button
copy this code in code window of form1

Private Sub Command1_Click()
Form2.Show
End Sub


---------------------------------------------
-Form2:
consists of a dtpicker and a command button
copy this code then
Private Sub Command1_Click()
Form1.Text1 = Format(DTPicker1.Value, "hh:mm")
Unload Me
End Sub

---------------------------------------------

Form1 is the startup form.

hope this helps!

-priya

0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 2

Expert Comment

by:priya_pbk
ID: 7100273
Also add this code in form2

-Form2:
Private Sub Form_Load()
DTPicker1.Value = Form1.Text1
End Sub

This will put the value of the text box back to the dtpicker1

-priya
0
 
LVL 2

Expert Comment

by:priya_pbk
ID: 7100275
check if the text1 in form1 is nullstring or not, helps to handle errors, like this

-Form2:
Private Sub Form_Load()
If Not Form1.Text1 = "" Then DTPicker1.Value = Form1.Text1
End Sub

as harsh008_k asked, do you want date or time. What is the format of your dtpicker control. I think one can have a date or time and not both.

-priya
0
 

Accepted Solution

by:
nermeen earned 200 total points
ID: 7100657
Hi
first of all set
Min and Max Date of Date Picker to defaults outside entry values
dtpControl.mindate = 0:dtpControl.MaxDate = "31/12/2099"

0
 

Author Comment

by:clive1
ID: 7103315
Thank you newmeen. I had a feeling that's what had to be done, but was unsure how to reset the min / max range, or to what limits to set them. It seems so easy when you have the answer.
Many thanks,
Clive
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

872 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