I've read a few posts about date formatting in SQL, but I can't seem to get it right. I have an update query but the final date it inputs into the table is 30-Dec-1899. The format is right but the date is not.
I have a pop-up form where I enter the date (the format is fine in both forms) and then it updates the dates on all selected records in the main form. Everything works fine, except it takes a long time to update (even just 2 records) and the date is wrong. Here's the code:
Any help would be much appreciated!
Erica
PS. Also, I can't seem to run the code line by line, it just beeps at me when I press F8, and when I select 'Step Into'. What am I doing wrong (I keep just going back to the form and hitting the command button, driving me nuts).
I have a pop-up form where I enter the date (the format is fine in both forms) and then it updates the dates on all selected records in the main form. Everything works fine, except it takes a long time to update (even just 2 records) and the date is wrong. Here's the code:
Code:
Private Sub cmdUpdate_Click()
DoCmd.SetWarnings False
Dim cnn1 As ADODB.Connection
Set cnn1 = CurrentProject.Connection
Dim rs1 As New ADODB.Recordset
rs1.ActiveConnection = cnn1
Dim SQL1 As String
Dim DX1 As Date
DX1 = Format(Forms!frmMark!txtDatePrep, "Medium")
SQL1 = "UPDATE tblDNA_Kit_Prep SET tblDNA_Kit_Prep.[Select] = False," & _
" tblDNA_Kit_Prep.DatePrepared = " & Forms!frmMark!txtDatePrep & "," & _
" tblDNA_Kit_Prep.PreparedBy_ID = " & [Forms]![frmMark]![cboSampler] & "," & _
" tblDNA_Kit_Prep.Status = 'Prepared'" & _
" WHERE tblDNA_Kit_Prep.[Select] = True"
rs1.Open SQL1
cnn1.Close
Set rs1 = Nothing
Set cnn1 = Nothing
DoCmd.SetWarnings True
DoCmd.Close acForm, "frmMark", acSaveNo
End Sub
Any help would be much appreciated!
Erica
PS. Also, I can't seem to run the code line by line, it just beeps at me when I press F8, and when I select 'Step Into'. What am I doing wrong (I keep just going back to the form and hitting the command button, driving me nuts).