Solved

Date time picker value from text field

Posted on 2002-06-21
7
333 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
[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
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
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 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

Enroll in June's Course of the Month

June's Course of the Month is now available! Every 10 seconds, a consumer gets hit with ransomware. Refresh your knowledge of ransomware best practices by enrolling in this month's complimentary course for Premium Members, Team Accounts, and Qualified Experts.

Question has a verified solution.

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

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…
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
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…
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…

688 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