Solved

Date time picker value from text field

Posted on 2002-06-21
7
326 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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
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 50 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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…

744 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now