Data from previous record (1 Viewer)

sloaner14

Registered User.
Local time
Today, 19:46
Joined
Apr 25, 2002
Messages
32
I have your standard customer, order, and order details database. In tblOrders, I have the the shipping address information. The reason it is in orders, a few clients can ship to different addresses and we need to track all orders and the shipping info. Here is what the boss wants. When a new order is placed for an existing customer, we need the customers previous order's shipping address to automaticly populate the new order's shipping address. I just can't seem to get it worked out in my head.
 

llkhoutx

Registered User.
Local time
Today, 14:46
Joined
Feb 26, 2001
Messages
4,018
Lookup the last order, if any, and capture it there. That code would be virtually instantaneous using a dbsnapshot.
 

sloaner14

Registered User.
Local time
Today, 19:46
Joined
Apr 25, 2002
Messages
32
Thanks for the reply. I have never done a dbsnapshot. Any hints on what to do.
 

llkhoutx

Registered User.
Local time
Today, 14:46
Joined
Feb 26, 2001
Messages
4,018
dim db as dao.database
dim rs as dao.recordset
set db=currentdb
set rs=db.openrecordset(YourShippingTableName,dbopenSnapshot)
set db=currentdb
rs.findlast "CustomerID=" & me.CustomerID
if rs.eof then
msgbox "Error, no record found for customer")
'take appropriuate action
end if
Me.sLastAddress = rs!Address
rs.close
db.close
set rs=nothing
set db=nothing

The forgoing assumes the "last" record for the customer is the correct one. some other criteria might be involved, depending on the order of the underlying table.

A snapshot is merely a copy of the recordset. Snapshots cannot be modified; dynasets (dbopendynaset) can be.

The foregoing, at least, should get you started in the right direction.
 

Users who are viewing this thread

Top Bottom