Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Basic button question.

Status
Not open for further replies.

SeaweedOPM

Technical User
Nov 19, 2004
53
US
This is a basic question but the forum search is down. I want a button on my form to, when clicked, will write in the "SalesData" table under the column "SalesDate" the current date. I think it has something to do with Now(). But I want the info to be recorded in the table for that day and not to change every day.
 
Here's what to put in the Event. Probably the "Click" event for that button.


Dim strSQL1 As String
Dim rst As New ADODB.Recordset

strSQL1 = "SELECT * FROM MyTable"

With rst
Set .ActiveConnection = CurrentProject.Connection
.CursorLocation = adUseClient
.CursorType = adOpenDynamic
.LockType = adLockOptimistic
.Open strSQL1
End With

If rst.RecordCount < 1 Then
Goto GetOutNow
Endif

rst!SalesDate = Now()
rst.Update


GetOutNow:
Set rst = Nothing


 
I agree with rssql, but would just like to add that, you need to state which record your on, so not to change the SAME record every day.

What distinguishes the row in the table, that your updating?

If it's the current record, then something like this...

strSQL1 = "SELECT * FROM MyTable WHERE pkID =" & Me.pkID

and just for the record, Now() will give you, time & date
4/23/2004 12:34:55

Date() will give you 2/23/2004

is this the right idea, or are you trying to keep a log of, how many times & when, the same record has been updated?

Either way, good luck!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top