473,385 Members | 1,341 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Date format from VBA Added to Table not correct and date is changed.

99 64KB
I am using Windows 10, MS Access 2016. I have date format in settings or regional settings (control panel) as
Short Date: dd/MM/yyyy
LOng Date: dd MMMM, yyyy.

In my Access Database, I have a table "LoginLogReport" with the following fields:

User ID: (Number)
Date: (Date/Time, Short Date)
Time: (Date/Time, Long Time)
Type: (Short Text, 25)

In a login form, in the click event of a Login command button, I am using the following code alongwith the other codelines.

Expand|Select|Wrap|Line Numbers
  1. strSQL = "INSERT INTO LoginLogReport (UserID, [Date], [Time], Type) " & _
  2.             "VALUES (" & Me.cboUser & ", #" & Date & "#, #" & Time & "#, 'Login')"
  3.     CurrentDb.Execute strSQL, dbFailOnError
  4.  
All is fine but the Date field shows the date (e.g., 06/08/2016, i.e., August 06, 2016) as (08/06/2016, i.e., June 08, 2016). When, in the table, I click on the floating calendar control, it takes me to the latter mentioned date. Please help me where is the fault?

Please help as soon as possible. Thank you.
Aug 6 '16 #1
4 1877
mshakeelattari
99 64KB
Is there no solution for this problem?
Aug 7 '16 #2
PhilOfWalton
1,430 Expert 1GB
Any sensible country would use a date format yyyy mm dd. The Brits, in their perverse way reverse this and are equally illogical in putting adjectives before nouns.
The Yanks are even more illogical in that their date format is completely random mm dd yyyy. Anyway, we're stuck with Microsoft being an American company, and we Brits have to overcome the problem.

I am unsure but this probably will sort out your problem
Expand|Select|Wrap|Line Numbers
  1. ?cdate(format(#10/05/16#,"Medium Date"))
  2. 05/10/2016 
  3.  
Anyway, that's what happens in the debug window.

Phil
Aug 7 '16 #3
mshakeelattari
99 64KB
Thank you for your reply. However, unfortunately this did not work for me.
Aug 9 '16 #4
mshakeelattari
99 64KB
When I used this code, it worked:
Expand|Select|Wrap|Line Numbers
  1. strSQL = "INSERT INTO LoginLogReport (UserID, [Date], [Time], Type) " & _
  2.             "VALUES (" & Me.cboUser & ", " & Format(Date, "\#mm\/dd\/yyyy\#") & ", #" & Time & "#, 'Login')"
Now I want to ask that, will it not create any issue if the app is used on a computer with some different Regional Settings of the Control Panel (or system locale),in which the date format is different one?
Aug 9 '16 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Funnyweb | last post by:
I have just notices that the date() function is not returning the correct date/time on my "server". I am running apache2 on my winxp pro laptop. My system clock is set to the correct date,...
15
by: Simon Brooke | last post by:
I'm investigating a bug a customer has reported in our database abstraction layer, and it's making me very unhappy. Brief summary: I have a database abstraction layer which is intended to...
8
by: Ishbel Kargar | last post by:
Since upgrading from old laptop (Windows 98) to new laptop (Windows XP), my mail-merge letters are doing strange things with date formats. For instance, my reminder letter for lapsed subs carries...
1
by: Dave Mann | last post by:
Right i have tried but failed! I have a Form and a subform Fields in Sub form are:- Planned - Checkbox Unplanned - Checkbox Maint Type - Dropdown selection Date Done Description
1
by: balleyman47 | last post by:
getting the following error when executing an insert statement: java.lang.IllegalArgumentException: Date/Time must be JDBC format running on UDB 8.2 fix pack 10 using IBM type IV driver. Query...
7
by: Richiep | last post by:
I am trying to get a UK format date of dd/mm/yyyy. Why does the following subroutine not return a valid date in a web form? The date returned is #12:00:00 AM# but the date I entered into the...
2
by: savigliano | last post by:
hello, i am doing a date comparation and i have reallize that the data i have in my database (general date format) it is causing me problems, and because i donīt need the time data i would like to...
2
by: Billy | last post by:
This string is supposed to provide all records from an MDB database that match the courier and date specified in the query. I Response.Write the query and I get a date as 1/27/2007. The date...
4
xstatic
by: xstatic | last post by:
After searching through the hundreds of links about "Javascript Date Formatting", all I am finding is how to format dates that gives a "current date" result. Here is what I need... I have a...
0
by: franknagy | last post by:
The moderator refused my question in this topic: "Try it yourself before you ask it". He/she is right. Here is my solution in Visual Prolog 5.2. 1. I defined a project with UI strategy "VPI"...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.