Passing info between databases

P

Patrick

HI!!
I was wondering if we can pass info(parameter perhaps) to
another database.

Ex.:
dbs1 and dbs2.

Lets say I'm working in dbs1 and need to send data to dbs2.
And I don't want another instance of access to open for
dbs2. It needs to stay invisible to the user.

The data could very well be just some sort of flag or even
a reponse to a function that executed just before
implementing this new code.

How would I accomplish this with VBA code.
Sorry! I don't have any code writen for you, I just don't
realy know where to start.

Thanx for any help in advance,
PAtrick
 
R

Roxie Aho

-----Original Message-----
HI!!
I was wondering if we can pass info(parameter perhaps) to
another database.
And I don't want another instance of access to open for
dbs2. It needs to stay invisible to the user.
<snip>

You didn't provide enough information for a specific
answer but try:

1. File>Get External Data > Link Tables

2. Take a look at DAO (Data Access Objects) or ADO
(ActiveX Data Objects). For information, start with
Access Help.

Roxie Aho
roxiea at usinternet.com
 
P

Patrick

Hi again!!

What if I wanted to pass a value(from dbs1) to a form in
dbs2 that value would change the way its loaded next time
dbs2 is open and that form is activated....

Does that make any sence!!
 
R

Roxie Aho

-----Original Message-----
Hi again!!

What if I wanted to pass a value(from dbs1) to a form in
dbs2 that value would change the way its loaded next time
dbs2 is open and that form is activated....

Does that make any sence!!
Values are stored in tables. A form presents values from
a table or a query based on a table(s). There is no data
per se in a form; it's in the table a form is based on.

If your form brings up records based on a value in a table
I think what you ask is possible. I'm trying but cannot
think of an example of what you ask. Perhaps, if you are
more specific, I or someone else can help.

Roxie Aho
roxiea at usinternet.com
 
G

Graham R Seach

Patrick,

If you just want to add data to a table in the other database, you can do it
this way.
Dim db As Database
Dim sSQL As String

Set db = OpenDatabase("C:\Documents and Settings\grahams\My
Documents\db1.mdb")
sSQL = "INSERT INTO tblTable (Field1, Field2) VALUES (" & intNumeric &
", """ & strAlpha & """)"
db.Execute sSQL, dbFailOnError

db.Close
Set db = Nothing

However, if you want to change the value of a form field in the other
database:
'Set a Reference to the Access Object Library
Dim acc As Access.Application
Dim frm As Form

'Instantiate a new Access.Application object
Set acc = New Access.Application

'Open the appropriate database
acc.OpenCurrentDatabase "C:\Documents and Settings\grahams\My
Documents\db1.mdb"
'Make it visible
acc.Visible = True

'Open the appropriate form
acc.DoCmd.OpenForm "Form1"
'Get a reference to it
Set frm = acc.Forms("Form1")

'Set the value of a textbox
frm!Text1 = "Hello"

'Release the form's object reference
Set frm = Nothing

'Clean up
acc.DoCmd.Close acForm, "Form1"
acc.CloseCurrentDatabase
acc.Quit acQuitSaveNone
Set acc = Nothing

Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia
 
G

Guest

Graham: thanks for does examples that's exactly what I
needed!!! I wasn't sure if it could be done.
But these example will help me a lot.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top