PC Review


Reply
Thread Tools Rate Thread

Amend code to autofill Date

 
 
=?Utf-8?B?R2FiYnkgR2lybA==?=
Guest
Posts: n/a
 
      10th Dec 2006
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

 
Reply With Quote
 
 
 
 
Douglas J. Steele
Guest
Posts: n/a
 
      10th Dec 2006
strSQL = "UPDATE tblTestRepairOrders SET Closed = True " & _
", DateCompleted = " & Format(Date(), "\#mm\/dd\/yyyy\#")


--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no private e-mails, please)


"Gabby Girl" <(E-Mail Removed)> wrote in message
news2382F5C-D951-4354-BBFC-(E-Mail Removed)...
> 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
>



 
Reply With Quote
 
=?Utf-8?B?R2FiYnkgR2lybA==?=
Guest
Posts: n/a
 
      10th Dec 2006
Works beautifully... Thank you so much Doug.
Have a great day.


"Douglas J. Steele" wrote:

> strSQL = "UPDATE tblTestRepairOrders SET Closed = True " & _
> ", DateCompleted = " & Format(Date(), "\#mm\/dd\/yyyy\#")
>
>
> --
> Doug Steele, Microsoft Access MVP
> http://I.Am/DougSteele
> (no private e-mails, please)
>
>
> "Gabby Girl" <(E-Mail Removed)> wrote in message
> news2382F5C-D951-4354-BBFC-(E-Mail Removed)...
> > 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
> >

>
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
amend a VB code please Morgan Microsoft Excel Misc 0 3rd Mar 2010 11:17 PM
Amend this Code-pls =?Utf-8?B?bXJiYWxhamU=?= Microsoft Outlook VBA Programming 1 11th Jun 2007 08:43 AM
How do I amend this code to ..... Mikey C Microsoft Excel Discussion 3 5th Apr 2007 11:58 AM
checkbox code to autofill date and once date hit unchecks itself =?Utf-8?B?Ymx1ZXpjcnVpemVy?= Microsoft Access Form Coding 3 17th Feb 2007 07:26 PM
Insufficient pemissions to amend Excel files but can amend Word fi =?Utf-8?B?RiBMYXVmcw==?= Microsoft Windows 2000 Security 0 11th Oct 2006 12:28 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:20 AM.