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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Updating a general time field in table 2

Status
Not open for further replies.

jpl458

Technical User
Sep 30, 2009
337
US
I have an older program that uses the following:
DoCmd.RunSQL "UPDATE Last_Update_Date SET Last_Update_Date.LastUpdate = Now()"
It works perfectly. But the old app is MDB

I have a new app That is accdb that uses the following:
DoCmd.RunSQL "UPDATE lastEupdateTbl SET lastEupdateTbl.LastUpdate = Now()"
It compiles but give me " You about to update 0 rows etc.

The code comes from the QBO grid and when it runs in there I get the same result.
Checked the names, all ok.

Could find any reference to this on the web.

Thanks is advance.

jpl
 
BTW I am using office 10 and windows 7.
jpl
 
How many rows are in the lastEupdateTbl ?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Only one. It tells me the time of the last update, and I use it to update only transaction that are past that date. I have looked at Time stamping but that saves the time of every transaction. As I said it works perfectly in MDB but not in ACCDB. I just tried up dating using the following:
dim Datetest as date
Datetest = now()
docmd.runsql "UPDATE LastEmailUpdate SET LastEmailUpdate.lastEupdate = '" & Datetest & "'"
I was hoping to fake it out, but no dice. If the above statement is right then you cant alter a date in a table, which seem weird.

Thanks

jpl
 
And this ?
DoCmd.RunSQL "UPDATE LastEmailUpdate SET lastEupdate=#" & Now & "#"

BTW, what is the data type of LastEmailUpdate.lastEupdate ?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Its DateTime formatted in the table as General Date.

Just tried

DoCmd.RunSQL "UPDATE LastEmailUpdate SET LastEmailUpdate.lastEupdate = #" & Now() & "#"

No joy.

I even tried changing the table def to text with:
Dim Testfield As Date
Dim Textfield As String
Testfield = Now()
Textfield = Format(CStr(Testfield), "mm:dd:yyyy hh:mm:ss AMPM")
DoCmd.RunSQL "UPDATE LastEmailUpdate SET LastEmailUpdate.lastEupdate = '" & Textfield & "'"

Stil 0 rows will be updated
 

Its DateTime formatted in the table as [highlight #FCE94F]General Date[/highlight].
... which is a NUMBER

don't think you want to change Date to String. I'd try...
Code:
Dim Testfield As Double
Dim Textfield As String
Testfield = Now()
Textfield = Format(Testfield, "yyyy/mm/dd hh:nn:ss AMPM")
DoCmd.RunSQL "UPDATE LastEmailUpdate SET LastEmailUpdate.lastEupdate = #" & Textfield & "#"

Skip,
[sub]
[glasses]Just traded in my OLD subtlety...
for a NUance![tongue][/sub]
 
Skip, it did the trick. I had to muddle trough some fat finger issues.

Thanks a lot.

jpl
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top