I have a textbox that is databound to a table in an access database.
The field only contains month/day/year but my databound textbox is
also showing a time. Is there any way to prevent it from doing this?
---
Kyote 9 2387
You can at least use format events http://www.vb-tips.com/DataBindingEvents.aspx
Cor
"Kyote" <ky********@nospamhotmail.comschreef in bericht
news:k7********************************@4ax.com...
>I have a textbox that is databound to a table in an access database.
The field only contains month/day/year but my databound textbox is
also showing a time. Is there any way to prevent it from doing this?
---
Kyote
Kyote wrote:
I have a textbox that is databound to a table in an access database.
The field only contains month/day/year
No, a Date/Time field actually always contains a time component, but the
time may be set to 00:00:00.
The value is read into the .NET type DateTime, which also always
contains a time component.
but my databound textbox is
also showing a time. Is there any way to prevent it from doing this?
Specify the FormatString in the Binding object.
--
Göran Andersson
_____ http://www.guffa.com
Cor,
Here is your example changed to use FormatString and NullValue properties: -
Public Class Form1
-
-
Private ds As New DataSet
-
-
Private Sub Form1_Load(ByVal sender As Object, ByVal e As
-
System.EventArgs) Handles Me.Load
-
-
Dim dt As New DataTable
-
ds.Tables.Add(dt)
-
dt.Columns.Add("DateField", GetType(System.DateTime))
-
dt.LoadDataRow(New Object() {New DateTime(2005, 8, 4)}, True)
-
dt.LoadDataRow(New Object() {Nothing}, True)
-
dt.LoadDataRow(New Object() {New DateTime(2005, 8, 5)}, True)
-
-
Dim Mybinding As New Binding("Text", ds.Tables(0), "DateField", True)
-
Mybinding.FormatString = "MM/dd/yyyy"
-
Mybinding.NullValue = "No date"
-
TextBox1.DataBindings.Add(Mybinding)
-
-
End Sub
-
-
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
-
System.EventArgs) Handles Button1.Click
-
-
'forward
-
Me.BindingContext(ds.Tables(0)).Position += 1
-
-
End Sub
-
-
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As
-
System.EventArgs) Handles Button2.Click
-
-
'backward
-
Me.BindingContext(ds.Tables(0)).Position -= 1
-
-
End Sub
-
End Class
-
Kerry Moorman
"Cor Ligthert[MVP]" wrote:
You can at least use format events
http://www.vb-tips.com/DataBindingEvents.aspx
Cor
"Kyote" <ky********@nospamhotmail.comschreef in bericht
news:k7********************************@4ax.com...
I have a textbox that is databound to a table in an access database.
The field only contains month/day/year but my databound textbox is
also showing a time. Is there any way to prevent it from doing this?
---
Kyote
Kerry,
Thanks
I will see if I can implement it, a problem with checking for nulls is often
that it makes the sample more difficult to read. It is about to tell how it
can be done.
"Learning to fish not giving the fish".
I started this were I needed it for dates before 1753 and than raised those
by 3000
Maybe I make 2 samples from it.
Cor
"Kerry Moorman" <Ke**********@discussions.microsoft.comschreef in bericht
news:45**********************************@microsof t.com...
Cor,
Here is your example changed to use FormatString and NullValue properties:
-
Public Class Form1
-
Private ds As New DataSet
-
Private Sub Form1_Load(ByVal sender As Object, ByVal e As
-
System.EventArgs) Handles Me.Load
-
Dim dt As New DataTable
-
ds.Tables.Add(dt)
-
dt.Columns.Add("DateField", GetType(System.DateTime))
-
dt.LoadDataRow(New Object() {New DateTime(2005, 8, 4)}, True)
-
dt.LoadDataRow(New Object() {Nothing}, True)
-
dt.LoadDataRow(New Object() {New DateTime(2005, 8, 5)}, True)
-
Dim Mybinding As New Binding("Text", ds.Tables(0), "DateField",
-
True)
-
Mybinding.FormatString = "MM/dd/yyyy"
-
Mybinding.NullValue = "No date"
-
TextBox1.DataBindings.Add(Mybinding)
-
End Sub
-
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
-
System.EventArgs) Handles Button1.Click
-
'forward
-
Me.BindingContext(ds.Tables(0)).Position += 1
-
End Sub
-
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As
-
System.EventArgs) Handles Button2.Click
-
'backward
-
Me.BindingContext(ds.Tables(0)).Position -= 1
-
End Sub
-
End Class
-
Kerry Moorman
"Cor Ligthert[MVP]" wrote:
>You can at least use format events
http://www.vb-tips.com/DataBindingEvents.aspx
Cor
"Kyote" <ky********@nospamhotmail.comschreef in bericht news:k7********************************@4ax.com.. .
>I have a textbox that is databound to a table in an access database.
The field only contains month/day/year but my databound textbox is
also showing a time. Is there any way to prevent it from doing this?
---
Kyote
On Thu, 16 Aug 2007 20:21:50 +0200, "Cor Ligthert[MVP]"
<no************@planet.nlwrote:
>You can at least use format events
http://www.vb-tips.com/DataBindingEvents.aspx
Thank you for the response Ken, and the help. I've done as it asked
and I'm currently playing around with it to try to understand all
that's happening. It does appear this would solve my problem. LOL
Looks like I'll be busy for a while trying to understand this.
---
Kyote
On Thu, 16 Aug 2007 21:00:36 +0200, Göran Andersson <gu***@guffa.com>
wrote:
>Kyote wrote:
>I have a textbox that is databound to a table in an access database. The field only contains month/day/year
No, a Date/Time field actually always contains a time component, but the time may be set to 00:00:00.
The value is read into the .NET type DateTime, which also always contains a time component.
>but my databound textbox is also showing a time. Is there any way to prevent it from doing this?
Specify the FormatString in the Binding object.
Thank you also for your response. I think your pretty much telling me
to do what Ken's example is showing me. With my limited understanding
of databinding and similar concepts this is going to take me quite a
while to understand, I have can understand it in a basic way even now.
So I have strong hopes of figuring out what all is happening to such a
degree that I can then make use of it for my app and any future app as
well.
Again, thank you for the help.
---
Kyote
Kerry,
The new Tip is here http://www.vb-tips.com/DataBindingFormatFields
Cor
"Kerry Moorman" <Ke**********@discussions.microsoft.comschreef in bericht
news:45**********************************@microsof t.com...
Cor,
Here is your example changed to use FormatString and NullValue properties:
-
Public Class Form1
-
Private ds As New DataSet
-
Private Sub Form1_Load(ByVal sender As Object, ByVal e As
-
System.EventArgs) Handles Me.Load
-
Dim dt As New DataTable
-
ds.Tables.Add(dt)
-
dt.Columns.Add("DateField", GetType(System.DateTime))
-
dt.LoadDataRow(New Object() {New DateTime(2005, 8, 4)}, True)
-
dt.LoadDataRow(New Object() {Nothing}, True)
-
dt.LoadDataRow(New Object() {New DateTime(2005, 8, 5)}, True)
-
Dim Mybinding As New Binding("Text", ds.Tables(0), "DateField",
-
True)
-
Mybinding.FormatString = "MM/dd/yyyy"
-
Mybinding.NullValue = "No date"
-
TextBox1.DataBindings.Add(Mybinding)
-
End Sub
-
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
-
System.EventArgs) Handles Button1.Click
-
'forward
-
Me.BindingContext(ds.Tables(0)).Position += 1
-
End Sub
-
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As
-
System.EventArgs) Handles Button2.Click
-
'backward
-
Me.BindingContext(ds.Tables(0)).Position -= 1
-
End Sub
-
End Class
-
Kerry Moorman
"Cor Ligthert[MVP]" wrote:
>You can at least use format events
http://www.vb-tips.com/DataBindingEvents.aspx
Cor
"Kyote" <ky********@nospamhotmail.comschreef in bericht news:k7********************************@4ax.com.. .
>I have a textbox that is databound to a table in an access database.
The field only contains month/day/year but my databound textbox is
also showing a time. Is there any way to prevent it from doing this?
---
Kyote
It does not show up in the link, we will have a look at the problem.
By hand it is there.
Cor
"Cor Ligthert[MVP]" <no************@planet.nlschreef in bericht
news:ui**************@TK2MSFTNGP04.phx.gbl...
Kerry,
The new Tip is here
http://www.vb-tips.com/DataBindingFormatFields
Cor
"Kerry Moorman" <Ke**********@discussions.microsoft.comschreef in
bericht news:45**********************************@microsof t.com...
>Cor,
Here is your example changed to use FormatString and NullValue properties:
- Public Class Form1
- Private ds As New DataSet
- Private Sub Form1_Load(ByVal sender As Object, ByVal e As
- System.EventArgs) Handles Me.Load
- Dim dt As New DataTable
- ds.Tables.Add(dt)
- dt.Columns.Add("DateField", GetType(System.DateTime))
- dt.LoadDataRow(New Object() {New DateTime(2005, 8, 4)}, True)
- dt.LoadDataRow(New Object() {Nothing}, True)
- dt.LoadDataRow(New Object() {New DateTime(2005, 8, 5)}, True)
- Dim Mybinding As New Binding("Text", ds.Tables(0), "DateField",
- True)
- Mybinding.FormatString = "MM/dd/yyyy"
- Mybinding.NullValue = "No date"
- TextBox1.DataBindings.Add(Mybinding)
- End Sub
- Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
- System.EventArgs) Handles Button1.Click
- 'forward
- Me.BindingContext(ds.Tables(0)).Position += 1
- End Sub
- Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As
- System.EventArgs) Handles Button2.Click
- 'backward
- Me.BindingContext(ds.Tables(0)).Position -= 1
- End Sub
- End Class
Kerry Moorman
"Cor Ligthert[MVP]" wrote:
>>You can at least use format events
http://www.vb-tips.com/DataBindingEvents.aspx
Cor
"Kyote" <ky********@nospamhotmail.comschreef in bericht news:k7********************************@4ax.com. .. I have a textbox that is databound to a table in an access database. The field only contains month/day/year but my databound textbox is also showing a time. Is there any way to prevent it from doing this?
--- Kyote
This should do it now. http://www.vb-tips.com/DataBindingFormatFields.aspx
Cor
"Cor Ligthert[MVP]" <no************@planet.nlschreef in bericht
news:Oq**************@TK2MSFTNGP02.phx.gbl...
It does not show up in the link, we will have a look at the problem.
By hand it is there.
Cor
"Cor Ligthert[MVP]" <no************@planet.nlschreef in bericht
news:ui**************@TK2MSFTNGP04.phx.gbl...
>Kerry,
The new Tip is here
http://www.vb-tips.com/DataBindingFormatFields
Cor
"Kerry Moorman" <Ke**********@discussions.microsoft.comschreef in bericht news:45**********************************@microsof t.com...
>>Cor,
Here is your example changed to use FormatString and NullValue properties:
- Public Class Form1
- Private ds As New DataSet
- Private Sub Form1_Load(ByVal sender As Object, ByVal e As
- System.EventArgs) Handles Me.Load
- Dim dt As New DataTable
- ds.Tables.Add(dt)
- dt.Columns.Add("DateField", GetType(System.DateTime))
- dt.LoadDataRow(New Object() {New DateTime(2005, 8, 4)}, True)
- dt.LoadDataRow(New Object() {Nothing}, True)
- dt.LoadDataRow(New Object() {New DateTime(2005, 8, 5)}, True)
- Dim Mybinding As New Binding("Text", ds.Tables(0), "DateField",
- True)
- Mybinding.FormatString = "MM/dd/yyyy"
- Mybinding.NullValue = "No date"
- TextBox1.DataBindings.Add(Mybinding)
- End Sub
- Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
- System.EventArgs) Handles Button1.Click
- 'forward
- Me.BindingContext(ds.Tables(0)).Position += 1
- End Sub
- Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As
- System.EventArgs) Handles Button2.Click
- 'backward
- Me.BindingContext(ds.Tables(0)).Position -= 1
- End Sub
- End Class
Kerry Moorman
"Cor Ligthert[MVP]" wrote:
You can at least use format events
http://www.vb-tips.com/DataBindingEvents.aspx
Cor
"Kyote" <ky********@nospamhotmail.comschreef in bericht news:k7********************************@4ax.com ... I have a textbox that is databound to a table in an access database. The field only contains month/day/year but my databound textbox is also showing a time. Is there any way to prevent it from doing this?
--- Kyote
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Joe User |
last post by:
Hi all....I have a feeling this is going to be one of those twisted query
questions, but here it goes anyways....
I want to generate a report that shows the chronology of events (represented
by...
|
by: Jan Nielsen |
last post by:
Hi
I have a dataform that shows a date from a MSDE 2000 in a textbox.
It uses the format: dd-mm-yyyy hh:mm:ss
It would it to use the format dd-mm-yyyy
But I can't find a Format property for the...
|
by: Bob |
last post by:
Hello:
I have an untyped dataset that uses an Access 2002 database.
For every record, it shows mm/dd/yyyy 12:00:00 AM in the textbox.
All I want to show is mm/dd/yyyy
I don't even know...
|
by: Jim in Arizona |
last post by:
I have a gridview that's being populated from an access db query. The
problem I'm having is that the date/time fields in access that are
populating the gridview are showing both date and time, when...
|
by: sandraz444 |
last post by:
I have an expression in the query under my form to autofill the date
under a certain condition but it wont write to the underlying table??
The date shows in the form but not the table. Does anyone...
| |
by: Luqman |
last post by:
Hi,
Any Idea how to Display Todays Date in DetailView Template Field while Inserting ?
For example: When I click on New Button of DetailView Control, I need to display Today's Date in a...
|
by: sheri |
last post by:
I have a field called date, the date is in the field like this 70925
(which means Sept. 25, 2007).
I have another field called day, it is a text field. How do I write a
query to populate the day...
|
by: Allen Browne |
last post by:
Paul, you *really* need to head Stuart's advice.
The data types are crucially important in database fields. Non-date values
(like the 3 letters TBC) are not valid dates, and cannot be evaluated...
|
by: =?Utf-8?B?ZGNoMw==?= |
last post by:
Is there a way to conditionally format a dateTime field to produce on result
if the value is 10/31/2008 12:00 AM (user didn't enter a time) and another
result if the value is 10/31/2008 5:30 PM...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
| |
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...
| |