INSERT INTO with Date Format MMMM YYYY (1 Viewer)

Malcolm17

Member
Local time
Today, 17:41
Joined
Jun 11, 2018
Messages
107
Hey All,

I'm trying to use an insert into statement to log an action in my system, I am looking to show the record with Printed on MMMM YYYY, however the date format is the issue at the end (I always seem to have an issue with date format, I just cannot get it.

Please can you tell me what my statement would need to be to do this, I'm using:

Code:
DoCmd.RunSQL "INSERT INTO tbl_Net_UserLog (Computer, UserName, SystemDate, Action) SELECT Forms.frmBackground.txtComputer & ' (' & Forms.frmBackground.txtComputerUser  & ')', Forms.frmBackground.txtUserName, Forms.frmBackground.txtLocalSystemDate, 'Printed ' & forms!frmbackground!subfrmBuyingList!cboBuyingList & ' Buying List for ' & Format(forms!frmbackground!subfrmBuyingList!cboBuyingListDate, "\#mmmm yyyy\#")"

the problem is with:

Code:
Format(forms!frmbackground!subfrmBuyingList!cboBuyingListDate, "\#mmmm yyyy\#")

Thank you
 

cheekybuddha

AWF VIP
Local time
Today, 17:41
Joined
Jul 21, 2014
Messages
2,280
Dates are dates - they are stored without format.

SQL requires an unambiguous date format when referring to dates. Either yyyy-mm-dd or mm/dd/yyyy

Use:
Code:
Format(forms!frmbackground!subfrmBuyingList!cboBuyingListDate, "\#yyyy\-mm\-dd\#")

Then, format it in the SELECT portion when you need to display the date.
 

Users who are viewing this thread

Top Bottom