Amend code to autofill Date

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello,

The following code works great (a big Thanks to Allen Browne), but now I
need the date auto filled in the DateCompleted field and I'm having trouble
as to where or what code to use.
~~~~~~~~~~~~
Private Sub cmdCloseROS_Click()
Dim strSQL As String

If Me.Dirty Then 'Save first.
Me.Dirty = False
End If
strSQL = "UPDATE tblTestRepairOrders SET Closed = True"
If Me.FilterOn Then
strSQL = strSQL & " WHERE " & Me.Filter
End If
Debug.Print strSQL
DBEngine(0)(0).Execute strSQL & ";", dbFailOnError

Me.Requery

End Sub

~~~~~~~

I tried adding: strSQL = "UPDATE tblTestRepairOrders SET DateCompleted =
Date", but that didn't work (I got Runtime Error 3061. Too few parameters.
Expected 1). So then I tried adding If Me.chkclosed = -1 Then
Me.DateCompleted = Date, but that didn't work either ( I got another Runtime
Error. Can't assign a value to this object). Now I'm totally lost.

Can anyone tell me how to amend the above code so it auto adds the date.

Thanks Kindly
 
strSQL = "UPDATE tblTestRepairOrders SET Closed = True " & _
", DateCompleted = " & Format(Date(), "\#mm\/dd\/yyyy\#")
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Excel Export Filtered Form Data To Excel 0
Change a report to a query 1
VBA code for my report 5
cannot delete from specified tables 7
Help with code 3
New Record 8
delete sub and stay on same parent record 4
strSQL code 5

Back
Top