Arg81
Well-known member
Hi guys,
Hope someone can help, this has had me pulling my hair out all morning.
On a small data entry form I have a few text boxes, a combobox and a dateTimePicker.
When the user fills in and clicks OK, it makes sure that all of the fields have been entered.
This is done by using a function called ValidData;
The problem I have is that by default DateTimePickers show the current date. Therefore the ValidData sees it has a value and marks it as true. But the value of the DTP is not being passed across when the user clicks OK.
Most of the time the dateTimePicker will need to show the current date anyway, it will only be changed when someone is filling the form out at a later date.
Is there a way that I can say "If dtpCreatedDate is Today() Then dtpCreatedDate.Value = dtpCreatedDate.Text"
I have tried the above but it doesn't work. I either need to get the dtp to take it's text and save as it's value, or get the validation part working and say "Open Dtp and click today's date".
Cheers,
Luke
Hope someone can help, this has had me pulling my hair out all morning.
On a small data entry form I have a few text boxes, a combobox and a dateTimePicker.
When the user fills in and clicks OK, it makes sure that all of the fields have been entered.
This is done by using a function called ValidData;
VB.NET:
[size=2][color=#0000ff]Private[/color][/size][size=2] [/size][size=2][color=#0000ff]Function[/color][/size][size=2] ValidData() [/size][size=2][color=#0000ff]As[/color][/size][size=2] [/size][size=2][color=#0000ff]Boolean
[/color][/size][size=2]ValidData = [/size][size=2][color=#0000ff]True
[/color][/size][size=2][/size][size=2][color=#0000ff]Dim[/color][/size][size=2] sMessage [/size][size=2][color=#0000ff]As[/color][/size][size=2] [/size][size=2][color=#0000ff]String
[/color][/size][size=2][/size][size=2][color=#0000ff]If[/color][/size][size=2] txtResponseHeader.Text = "" [/size][size=2][color=#0000ff]Then
[/color][/size][size=2]ValidData = [/size][size=2][color=#0000ff]False
[/color][/size][size=2]sMessage = "Please enter a Response Header"
[/size][size=2][color=#0000ff]End[/color][/size][size=2] [/size][size=2][color=#0000ff]If
[/color][/size][size=2][/size][size=2][color=#0000ff]If[/color][/size][size=2] txtResponse.Text = "" [/size][size=2][color=#0000ff]Then
[/color][/size][size=2]ValidData = [/size][size=2][color=#0000ff]False
[/color][/size][size=2]sMessage = "Please enter Response details"
[/size][size=2][color=#0000ff]End[/color][/size][size=2] [/size][size=2][color=#0000ff]If
[/color][/size][size=2][/size][size=2][color=#0000ff]If[/color][/size][size=2] cboCreatedBy.Text = "" [/size][size=2][color=#0000ff]Then
[/color][/size][size=2]ValidData = [/size][size=2][color=#0000ff]False
[/color][/size][size=2]sMessage = "Please select who created Response"
[/size][size=2][color=#0000ff]End[/color][/size][size=2] [/size][size=2][color=#0000ff]If
[/color][/size][size=2][/size][size=2][color=#0000ff]If[/color][/size][size=2] dtpCreatedDate.Text = "" [/size][size=2][color=#0000ff]Then
[/color][/size][size=2]ValidData = [/size][size=2][color=#0000ff]False
[/color][/size][size=2]sMessage = "Please select date Response took place"
[/size][size=2][color=#0000ff]End[/color][/size][size=2] [/size][size=2][color=#0000ff]If
[/color][/size][size=2][/size][size=2][color=#0000ff]If[/color][/size][size=2] [/size][size=2][color=#0000ff]Not[/color][/size][size=2] ValidData [/size][size=2][color=#0000ff]Then
[/color][/size][size=2]MessageBox.Show(sMessage, "Data Entry Error", MessageBoxButtons.OK, MessageBoxIcon.Information)
[/size][size=2][color=#0000ff]End[/color][/size][size=2] [/size][size=2][color=#0000ff]If
[/color][/size][size=2][/size][size=2][color=#0000ff]End[/color][/size][size=2] [/size][size=2][color=#0000ff]Function
[/color][/size]
The problem I have is that by default DateTimePickers show the current date. Therefore the ValidData sees it has a value and marks it as true. But the value of the DTP is not being passed across when the user clicks OK.
Most of the time the dateTimePicker will need to show the current date anyway, it will only be changed when someone is filling the form out at a later date.
Is there a way that I can say "If dtpCreatedDate is Today() Then dtpCreatedDate.Value = dtpCreatedDate.Text"
I have tried the above but it doesn't work. I either need to get the dtp to take it's text and save as it's value, or get the validation part working and say "Open Dtp and click today's date".
Cheers,
Luke