How to save data into 2 database

deanvilar

Registered User.
Local time
Today, 11:24
Joined
Mar 27, 2013
Messages
63
Hello Gurus,

How to save another data into another database taking the last "moveCode" of another database?

below sample of saving a data in the current DB.

Private Sub cmdSave_Click()

Set db = CurrentDb
Set rst = db.OpenRecordset("fuelMngtTable")

If Me.txtAssetNo = "" Then
MsgBox "Asset Number should not be blank!", vbCritical
Me.txtAssetNo.SetFocus
Else
With rst
.AddNew
!assetCtr = Me.txtAssetCtr
!assetNo = Me.txtAssetNo
!compCode = Me.cmbCompCode
!compCodeDesc = Me.txtCompCodeDesc
!assetDesc = Me.txtAssetDesc
!equipType = Me.cmbEquipType
!model = Me.txtEquipModel
.Update
End With
rst.Close

Set rst = Nothing
Set db = Nothing
'====================
'OPEN DATABASE ASSET MNGT RUNNING COST THEN TAKE THE LAST "moveCode" THEN SAVE ALL DATA ABOVE TO DATABASE ASSET MNGT RUNNING COST
 
which table in assent mngt should the data saved?

also specify the datatype of the ff:

assetCtr
assetNo
compCode
compCodeDesc
assetDesc
equipType
model

actually it can be done like this without opening the second database:

dim rs as dao.recordset
dim varMoveCode as variant
set rs=dbengine(0)(0).openrecordset("select max(movecode) from yourtable in 'z:\test.accdb'"
varMoveCode = rs(0)
set rs=nothing
dbengine(0)(0).execute "update yourtable in 'z:\test.accdb' set field1=xxx, field2=xxx;"

'**** end code

provide the correct names for the blue letters.
 
Last edited:

Users who are viewing this thread

Back
Top Bottom