We have an old MS Access database that we moved to SQL Server but we’re still using the Access forms for the front end until we can get a web front end built. I’m having a hard time trying to get the dates formatted correctly when being sent to the SQL database via the linked tables.
Date shows up like this
I bolded the code below where I'm trying to get the date part completed, Any help is appreciated and thanks in advance.
Code:
TerminatedYear = DatePart("yyyy", [Date])
FormattedDate = Year(Date)
Dim conn As ADODB.Connection
Dim strSQL As String
Dim LDate As String
Set conn = CurrentProject.Connection
strSQL = "INSERT INTO termDate_Tracking(FacilityID,terminationDate,TermYear) VALUES(" & _
FacilityID & ", " & FormattedDate & ", " & TerminatedYear & ")"
conn.Execute strSQL
conn.Close
Set conn = Nothing
Me.Requery