A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Running & Setting Up Queries
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Need help with updating with value from another database



 
 
Thread Tools Display Modes
  #11  
Old September 20th, 2005, 12:22 AM
MGFoster
external usenet poster
 
Posts: n/a
Default

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Right... I've neglected some basics (losing my mind). Should have
single quote delimiters around parameter VName. The d_DateTime subquery
should return a DateTime data type so it doesn't need any delimiters.

UPDATE VehDetail

SET LastOdometerDate = DMax("d_DateTime",
"[Database=C:\VMS\VMSDB\Ats20050907Db.mdb;].DATA",
"d_RemoteName = '" & VehDetail.VName & "'" ),

LastOdometerReading = DMax("d_OdometerTenths",
"[Database=C:\VMS\VMSDB\Ats20050907Db.mdb;].DATA",
"d_RemoteName = '" & VehDetail.VName & "'" &
" AND d_DateTime = (SELECT Max(d_DateTime)
FROM [Database=C:\VMS\VMSDB\Ats20050907Db.mdb;].DATA
WHERE d_RemoteName = '" & VehDetail.VName & "')" )

It might be possible that the use of concatenation and string delimiters
is not needed. E.g.:

... "d-RemoteName = VehDetail.VName")

I'm not sure - test & see.

Also, not sure if the subquery in the LastOdometerReading setting will
work. If not, you'll have to create another DMax() function inside the
DMax() function - fun!

... " AND d_DateTime = DMax("d_DateTime",
"[Database=C:\VMS\VMSDB\Ats20050907Db.mdb;].DATA",
"d_RemoteName = '" & VehDetail.VName & "'" )

Another solution is to dump the aggregated data into a temp table & use
that table's data as the right-side of the SET expressions. E.g.:

UPDATE VehDetail
SET LastOdometerDate = (SELECT MaxOfDateTime FROM temp
WHERE d_RemoteName = VehDetail.VName),
LastOdometerReading = (SELECT MaxOfOdometer FROM temp ...

--
MGFoster:::mgf00 at earthlink decimal-point net
Oakland, CA (USA)

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBQy9IHIechKqOuFEgEQJg8gCfTHKiqjUyGbN5ag0mDYjbBP s9xTUAoPmk
OO5ho02bDuWymoR5Y0/N4UBM
=zS4j
-----END PGP SIGNATURE-----

Alpha wrote:
The "&", are they being used to concatenate a string?

"MGFoster" wrote:


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Ah, yes. I forgot that Access is stupid about ANSI-92 UPDATE
statements. It won't allow aggregate subqueries in the SET clause.
Therefore, you have to use domain aggregate functions DMax(), DLookup(),
etc., which slows down UPDATES on large data sets.

Try the below (untested):

UPDATE VehDetail

SET LastOdometerDate = DMax("d_DateTime",
"[Database=C:\VMS\VMSDB\Ats20050907Db.mdb;].DATA",
"d_RemoteName = " & VehDetail.VName ),

LastOdometerReading = DMax("d_OdometerTenths",
"[Database=C:\VMS\VMSDB\Ats20050907Db.mdb;].DATA",
"d_RemoteName = " & VehDetail.VName &
" AND d_DateTime] = (SELECT Max(d_DateTime)
FROM [Database=C:\VMS\VMSDB\Ats20050907Db.mdb;].DATA
WHERE d_RemoteName = " & VehDetail.VName & ")" )

--
MGFoster:::mgf00 at earthlink decimal-point net

  #12  
Old September 20th, 2005, 09:57 PM
Alpha
external usenet poster
 
Posts: n/a
Default

I 've modified the query according to the sytax for DMAX in the Access books
online which could accept 3 strings as paramenters. That doesn't work and
has syntax errors that I can't find. I also tried just setting first field
and that gives me a "Unknown" display in a messagebox without further
information.

I'm sorry to keep bugging you but I really need to get this working and
can't figure out how to do this at all.

Thanks, Alpha


UPDATE VehDetail

SET LastOdometerDate = DMax("d_DateTime",
"[Database=C:\VMS\VMSDB\Ats20050907Db.mdb;].DATA",
"d_RemoteName = VehDetail.VName" ),

LastOdometerReading = DMax("d_OdometerTenths",
"[Database=C:\VMS\VMSDB\Ats20050907Db.mdb;].DATA",
"d_RemoteName =VehDetail.VName
AND d_DateTime = DMax("d_DateTime",
"[Database=C:\VMS\VMSDB\Ats20050907Db.mdb;].DATA",
"d_RemoteName =VehDetail.VName")" );

"MGFoster" wrote:

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Right... I've neglected some basics (losing my mind). Should have
single quote delimiters around parameter VName. The d_DateTime subquery
should return a DateTime data type so it doesn't need any delimiters.

UPDATE VehDetail

SET LastOdometerDate = DMax("d_DateTime",
"[Database=C:\VMS\VMSDB\Ats20050907Db.mdb;].DATA",
"d_RemoteName = '" & VehDetail.VName & "'" ),

LastOdometerReading = DMax("d_OdometerTenths",
"[Database=C:\VMS\VMSDB\Ats20050907Db.mdb;].DATA",
"d_RemoteName = '" & VehDetail.VName & "'" &
" AND d_DateTime = (SELECT Max(d_DateTime)
FROM [Database=C:\VMS\VMSDB\Ats20050907Db.mdb;].DATA
WHERE d_RemoteName = '" & VehDetail.VName & "')" )

It might be possible that the use of concatenation and string delimiters
is not needed. E.g.:

... "d-RemoteName = VehDetail.VName")

I'm not sure - test & see.

Also, not sure if the subquery in the LastOdometerReading setting will
work. If not, you'll have to create another DMax() function inside the
DMax() function - fun!

... " AND d_DateTime = DMax("d_DateTime",
"[Database=C:\VMS\VMSDB\Ats20050907Db.mdb;].DATA",
"d_RemoteName = '" & VehDetail.VName & "'" )

Another solution is to dump the aggregated data into a temp table & use
that table's data as the right-side of the SET expressions. E.g.:

UPDATE VehDetail
SET LastOdometerDate = (SELECT MaxOfDateTime FROM temp
WHERE d_RemoteName = VehDetail.VName),
LastOdometerReading = (SELECT MaxOfOdometer FROM temp ...

--
MGFoster:::mgf00 at earthlink decimal-point net
Oakland, CA (USA)

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBQy9IHIechKqOuFEgEQJg8gCfTHKiqjUyGbN5ag0mDYjbBP s9xTUAoPmk
OO5ho02bDuWymoR5Y0/N4UBM
=zS4j
-----END PGP SIGNATURE-----

Alpha wrote:
The "&", are they being used to concatenate a string?

"MGFoster" wrote:


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Ah, yes. I forgot that Access is stupid about ANSI-92 UPDATE
statements. It won't allow aggregate subqueries in the SET clause.
Therefore, you have to use domain aggregate functions DMax(), DLookup(),
etc., which slows down UPDATES on large data sets.

Try the below (untested):

UPDATE VehDetail

SET LastOdometerDate = DMax("d_DateTime",
"[Database=C:\VMS\VMSDB\Ats20050907Db.mdb;].DATA",
"d_RemoteName = " & VehDetail.VName ),

LastOdometerReading = DMax("d_OdometerTenths",
"[Database=C:\VMS\VMSDB\Ats20050907Db.mdb;].DATA",
"d_RemoteName = " & VehDetail.VName &
" AND d_DateTime] = (SELECT Max(d_DateTime)
FROM [Database=C:\VMS\VMSDB\Ats20050907Db.mdb;].DATA
WHERE d_RemoteName = " & VehDetail.VName & ")" )

--
MGFoster:::mgf00 at earthlink decimal-point net


  #13  
Old September 20th, 2005, 10:09 PM
Alpha
external usenet poster
 
Posts: n/a
Default

I tried the following and it also gives me the "Unknown" message box.

UPDATE VehDetail

SET LastOdometerDate = DMax("d_DateTime",
"[Database=C:\VMS\VMSDB\Ats20050907Db.mdb;].DATA",
"DATA.d_RemoteName = VehDetail.VName" ),

LastOdometerReading = DMax("d_OdometerTenths",
"[Database=C:\VMS\VMSDB\Ats20050907Db.mdb;].DATA",
"DATA.d_RemoteName =VehDetail.VName");


"MGFoster" wrote:

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Right... I've neglected some basics (losing my mind). Should have
single quote delimiters around parameter VName. The d_DateTime subquery
should return a DateTime data type so it doesn't need any delimiters.

UPDATE VehDetail

SET LastOdometerDate = DMax("d_DateTime",
"[Database=C:\VMS\VMSDB\Ats20050907Db.mdb;].DATA",
"d_RemoteName = '" & VehDetail.VName & "'" ),

LastOdometerReading = DMax("d_OdometerTenths",
"[Database=C:\VMS\VMSDB\Ats20050907Db.mdb;].DATA",
"d_RemoteName = '" & VehDetail.VName & "'" &
" AND d_DateTime = (SELECT Max(d_DateTime)
FROM [Database=C:\VMS\VMSDB\Ats20050907Db.mdb;].DATA
WHERE d_RemoteName = '" & VehDetail.VName & "')" )

It might be possible that the use of concatenation and string delimiters
is not needed. E.g.:

... "d-RemoteName = VehDetail.VName")

I'm not sure - test & see.

Also, not sure if the subquery in the LastOdometerReading setting will
work. If not, you'll have to create another DMax() function inside the
DMax() function - fun!

... " AND d_DateTime = DMax("d_DateTime",
"[Database=C:\VMS\VMSDB\Ats20050907Db.mdb;].DATA",
"d_RemoteName = '" & VehDetail.VName & "'" )

Another solution is to dump the aggregated data into a temp table & use
that table's data as the right-side of the SET expressions. E.g.:

UPDATE VehDetail
SET LastOdometerDate = (SELECT MaxOfDateTime FROM temp
WHERE d_RemoteName = VehDetail.VName),
LastOdometerReading = (SELECT MaxOfOdometer FROM temp ...

--
MGFoster:::mgf00 at earthlink decimal-point net
Oakland, CA (USA)

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBQy9IHIechKqOuFEgEQJg8gCfTHKiqjUyGbN5ag0mDYjbBP s9xTUAoPmk
OO5ho02bDuWymoR5Y0/N4UBM
=zS4j
-----END PGP SIGNATURE-----

Alpha wrote:
The "&", are they being used to concatenate a string?

"MGFoster" wrote:


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Ah, yes. I forgot that Access is stupid about ANSI-92 UPDATE
statements. It won't allow aggregate subqueries in the SET clause.
Therefore, you have to use domain aggregate functions DMax(), DLookup(),
etc., which slows down UPDATES on large data sets.

Try the below (untested):

UPDATE VehDetail

SET LastOdometerDate = DMax("d_DateTime",
"[Database=C:\VMS\VMSDB\Ats20050907Db.mdb;].DATA",
"d_RemoteName = " & VehDetail.VName ),

LastOdometerReading = DMax("d_OdometerTenths",
"[Database=C:\VMS\VMSDB\Ats20050907Db.mdb;].DATA",
"d_RemoteName = " & VehDetail.VName &
" AND d_DateTime] = (SELECT Max(d_DateTime)
FROM [Database=C:\VMS\VMSDB\Ats20050907Db.mdb;].DATA
WHERE d_RemoteName = " & VehDetail.VName & ")" )

--
MGFoster:::mgf00 at earthlink decimal-point net


 




Thread Tools
Display Modes

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

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Updating ODBC tables from Access Query cg084 Running & Setting Up Queries 1 August 30th, 2005 05:09 PM
Subform not updating table Sue Using Forms 2 August 16th, 2005 07:21 PM
Updating Address Book in cache mode Lori Pearce \(MSFT\) General Discussion 1 February 4th, 2005 03:29 AM
Updating Two Related Fields in One Query SANJAY SHAH \(MICROBRAIN Computers Pvt. Ltd.\) Running & Setting Up Queries 3 June 9th, 2004 12:23 PM
Updating 2 tables with 1 form - Access 2003 Linger1974 Running & Setting Up Queries 4 May 27th, 2004 12:30 AM


All times are GMT +1. The time now is 09:12 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.