:?: How do I change the input and display of the dtpicker control to "dd/mm/yy" format. Also how do I store it in an MS-Access database in the same format (ie. dd/mm/yy ) . ... need help urgently!
Regards,
Swati
:?: How do I change the input and display of the dtpicker control to "dd/mm/yy" format. Also how do I store it in an MS-Access database in the same format (ie. dd/mm/yy ) . ... need help urgently!
Regards,
Swati
Quick summary and corrections (builds on replies by and ):
The DTPicker is only a display/input control — it does not change how Access stores the value. Keep the field in Access as a Date/Time type and format the display when you show it. was right to warn about CustomFormat overriding the user locale; ’s post has typos (property is CustomFormat, not "CoustomFormate") and the direct string concatenation to build SQL is unsafe and locale‑fragile.
How to wire this safely and predictably:
dd/mm/yyyy) rather than changing stored data.Examples (safe patterns):
DAO recordset (Access/VBA-friendly pattern):
Dim rs As DAO.Recordset
Set rs = CurrentDb.OpenRecordset("Table1", dbOpenDynaset)
rs.AddNew
rs!iDate = DTPicker1.Value
rs.Update
rs.Close ADO parameter (VB6 / ADO):
Dim cn As ADODB.Connection
Dim cmd As ADODB.Command
Set cn = New ADODB.Connection
cn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Path\MyDB.mdb;"
Set cmd = New ADODB.Command
With cmd
.ActiveConnection = cn
.CommandText = "INSERT INTO Table1 (iDate) VALUES (?)"
.CommandType = adCmdText
.Parameters.Append .CreateParameter("pDate", adDBTimeStamp, adParamInput, , DTPicker1.Value)
.Execute
End With
cn.Close Troubleshooting notes:
yyyy) for clarity.These steps avoid regional/locale surprises and prevent SQL errors and injection risk while giving the dd/mm display you want.
Jump to Post— davidcairns 1For dtPicker you can use the dtPicker.Format to set it to whatever you want, including dtpShortDate and dtpCustom. If you use custom then dtPicker.CustomFormat can be set to any format (including "dd/mm/yy") however this will then ignore the users regional settings. Hence short date is probably the best choice for …
For dtPicker you can use the dtPicker.Format to set it to whatever you want, including dtpShortDate and dtpCustom. If you use custom then dtPicker.CustomFormat can be set to any format (including "dd/mm/yy") however this will then ignore the users regional settings. Hence short date is probably the best choice for what you want.
As for storing it in Access, always store it as a date and then when you want to display it do the formatting. You should never store dates as strings in the database. Set the date format either in your SELECT statement or at the point where the data is displayed to the user.
Regards
D
help me with the dtpicker code
please help me with the code that dislays the functionality of the dtpicker
Here you Go...
1:- Firs Place one DTPicker1 on Form.
2:- Go To DTPicker1 Properties and Set Format = 3-dtpCoustom.
3:- Private Sub Form_Load()
DTPicker1.CoustomFormate = "dd-MM-yy"
End Sub
4:- Private Sub Command1_Click()
Dim db As Database
db.Execute ("INSERT InTo Tabel1(iDate) Values(' " & DTPicker1.Value & " ' ")
End Sub
Hope you clear..
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.