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. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
VB to Access via DDE
Hello all,
Is there any way for a VB application to communicate with an Access application via DDE? I want to be able to send text box data to Access forms, click buttons and menu bars from an external application. Thanks in advance, Jonathan |
#2
|
|||
|
|||
VB to Access via DDE
Jonathan,
Yes, the process is called "automation". The following is referred to as "early binding". It is the easiest, and most functional because it gives you access to Intellisense, but it is version-dependent. If you want version independence, you have to use "late binding". Add a reference to the Access type library Dim acc As Access.Application Dim db As DAO.Database Set acc = New Access.Application acc.OpenCurrentDatabase "path to database.mdb" Set db = acc.CurrentDb acc.Forms!frmMyForm!txtSomeTextbox = "abc" acc.Quit acQuitSaveNone acc.CloseCurrentDatabase Set db = Nothing Set acc = Nothing To use "late binding"... Dim acc As Object Dim db As DAO.Database Set acc = CreateObject("Access.Application") Regards, Graham R Seach Microsoft Access MVP Sydney, Australia --------------------------- "Jonathan" wrote in message ... Hello all, Is there any way for a VB application to communicate with an Access application via DDE? I want to be able to send text box data to Access forms, click buttons and menu bars from an external application. Thanks in advance, Jonathan |
#3
|
|||
|
|||
VB to Access via DDE
Graham
This looks good. Can you navigate menu bars and click buttons this way? Jonathan "Graham R Seach" wrote in message ... Jonathan, Yes, the process is called "automation". The following is referred to as "early binding". It is the easiest, and most functional because it gives you access to Intellisense, but it is version-dependent. If you want version independence, you have to use "late binding". Add a reference to the Access type library Dim acc As Access.Application Dim db As DAO.Database Set acc = New Access.Application acc.OpenCurrentDatabase "path to database.mdb" Set db = acc.CurrentDb acc.Forms!frmMyForm!txtSomeTextbox = "abc" acc.Quit acQuitSaveNone acc.CloseCurrentDatabase Set db = Nothing Set acc = Nothing To use "late binding"... Dim acc As Object Dim db As DAO.Database Set acc = CreateObject("Access.Application") Regards, Graham R Seach Microsoft Access MVP Sydney, Australia --------------------------- "Jonathan" wrote in message ... Hello all, Is there any way for a VB application to communicate with an Access application via DDE? I want to be able to send text box data to Access forms, click buttons and menu bars from an external application. Thanks in advance, Jonathan |
#4
|
|||
|
|||
VB to Access via DDE
Yes you can use Access as a DDE server but why would you want to(?) when you
can use OLE automation which is much easier. Have a look at the url below for DDE stuff:- http://msdn.microsoft.com/library/de...HV05186349.asp -- Terry Kreft "Jonathan" wrote in message ... Hello all, Is there any way for a VB application to communicate with an Access application via DDE? I want to be able to send text box data to Access forms, click buttons and menu bars from an external application. Thanks in advance, Jonathan |
#5
|
|||
|
|||
VB to Access via DDE
Jonathan,
Once you get at the Access application object, you can do anything you want. Just preface everything with acc (if that's what your Access application object is called). Regards, Graham R Seach Microsoft Access MVP Sydney, Australia --------------------------- "Jonathan" wrote in message ... Graham This looks good. Can you navigate menu bars and click buttons this way? Jonathan "Graham R Seach" wrote in message ... Jonathan, Yes, the process is called "automation". The following is referred to as "early binding". It is the easiest, and most functional because it gives you access to Intellisense, but it is version-dependent. If you want version independence, you have to use "late binding". Add a reference to the Access type library Dim acc As Access.Application Dim db As DAO.Database Set acc = New Access.Application acc.OpenCurrentDatabase "path to database.mdb" Set db = acc.CurrentDb acc.Forms!frmMyForm!txtSomeTextbox = "abc" acc.Quit acQuitSaveNone acc.CloseCurrentDatabase Set db = Nothing Set acc = Nothing To use "late binding"... Dim acc As Object Dim db As DAO.Database Set acc = CreateObject("Access.Application") Regards, Graham R Seach Microsoft Access MVP Sydney, Australia --------------------------- "Jonathan" wrote in message ... Hello all, Is there any way for a VB application to communicate with an Access application via DDE? I want to be able to send text box data to Access forms, click buttons and menu bars from an external application. Thanks in advance, Jonathan |
#6
|
|||
|
|||
VB to Access via DDE
"Jonathan" wrote in message ... Hello all, Is there any way for a VB application to communicate with an Access application via DDE? I want to be able to send text box data to Access forms, click buttons and menu bars from an external application. Thanks in advance, Jonathan Yes. There are plenty of examples in both the VB and MSAccess help files. Lookup "dde functions poke". Note: not all examples will be specific to MSAccess, (usually Excel), but they will work with any application that supports DDE. -ralph |
#7
|
|||
|
|||
VB to Access via DDE
Maybe I'm missing something obvious but what combination of commands do you
use to click a button on a form?? Also I found that I had to execute acc!DoCmd.OpenForm "Form1" before I could but anything in a text box. Jonathan "Graham R Seach" wrote in message ... Jonathan, Once you get at the Access application object, you can do anything you want. Just preface everything with acc (if that's what your Access application object is called). Regards, Graham R Seach Microsoft Access MVP Sydney, Australia --------------------------- "Jonathan" wrote in message ... Graham This looks good. Can you navigate menu bars and click buttons this way? Jonathan "Graham R Seach" wrote in message ... Jonathan, Yes, the process is called "automation". The following is referred to as "early binding". It is the easiest, and most functional because it gives you access to Intellisense, but it is version-dependent. If you want version independence, you have to use "late binding". Add a reference to the Access type library Dim acc As Access.Application Dim db As DAO.Database Set acc = New Access.Application acc.OpenCurrentDatabase "path to database.mdb" Set db = acc.CurrentDb acc.Forms!frmMyForm!txtSomeTextbox = "abc" acc.Quit acQuitSaveNone acc.CloseCurrentDatabase Set db = Nothing Set acc = Nothing To use "late binding"... Dim acc As Object Dim db As DAO.Database Set acc = CreateObject("Access.Application") Regards, Graham R Seach Microsoft Access MVP Sydney, Australia --------------------------- "Jonathan" wrote in message ... Hello all, Is there any way for a VB application to communicate with an Access application via DDE? I want to be able to send text box data to Access forms, click buttons and menu bars from an external application. Thanks in advance, Jonathan |
#8
|
|||
|
|||
VB to Access via DDE
You don't click the button: you call the procedure (or macro) that's defined
for the click event. Assuming the button is named MyButton, you'd do something like: Call acc.Forms("Form1").MyButton_Click Note that this requires that you change the declaration from Private Sub MyButton_Click() to Public Sub MyButton_Click(). -- Doug Steele, Microsoft Access MVP http://I.Am/DougSteele (no private e-mails, please) "Jonathan" wrote in message ... Maybe I'm missing something obvious but what combination of commands do you use to click a button on a form?? Also I found that I had to execute acc!DoCmd.OpenForm "Form1" before I could but anything in a text box. Jonathan "Graham R Seach" wrote in message ... Jonathan, Once you get at the Access application object, you can do anything you want. Just preface everything with acc (if that's what your Access application object is called). Regards, Graham R Seach Microsoft Access MVP Sydney, Australia --------------------------- "Jonathan" wrote in message ... Graham This looks good. Can you navigate menu bars and click buttons this way? Jonathan "Graham R Seach" wrote in message ... Jonathan, Yes, the process is called "automation". The following is referred to as "early binding". It is the easiest, and most functional because it gives you access to Intellisense, but it is version-dependent. If you want version independence, you have to use "late binding". Add a reference to the Access type library Dim acc As Access.Application Dim db As DAO.Database Set acc = New Access.Application acc.OpenCurrentDatabase "path to database.mdb" Set db = acc.CurrentDb acc.Forms!frmMyForm!txtSomeTextbox = "abc" acc.Quit acQuitSaveNone acc.CloseCurrentDatabase Set db = Nothing Set acc = Nothing To use "late binding"... Dim acc As Object Dim db As DAO.Database Set acc = CreateObject("Access.Application") Regards, Graham R Seach Microsoft Access MVP Sydney, Australia --------------------------- "Jonathan" wrote in message ... Hello all, Is there any way for a VB application to communicate with an Access application via DDE? I want to be able to send text box data to Access forms, click buttons and menu bars from an external application. Thanks in advance, Jonathan |
#9
|
|||
|
|||
VB to Access via DDE
Duhh! Thanks Doug!
Jonathan "Douglas J. Steele" wrote in message ... You don't click the button: you call the procedure (or macro) that's defined for the click event. Assuming the button is named MyButton, you'd do something like: Call acc.Forms("Form1").MyButton_Click Note that this requires that you change the declaration from Private Sub MyButton_Click() to Public Sub MyButton_Click(). -- Doug Steele, Microsoft Access MVP http://I.Am/DougSteele (no private e-mails, please) "Jonathan" wrote in message ... Maybe I'm missing something obvious but what combination of commands do you use to click a button on a form?? Also I found that I had to execute acc!DoCmd.OpenForm "Form1" before I could but anything in a text box. Jonathan "Graham R Seach" wrote in message ... Jonathan, Once you get at the Access application object, you can do anything you want. Just preface everything with acc (if that's what your Access application object is called). Regards, Graham R Seach Microsoft Access MVP Sydney, Australia --------------------------- "Jonathan" wrote in message ... Graham This looks good. Can you navigate menu bars and click buttons this way? Jonathan "Graham R Seach" wrote in message ... Jonathan, Yes, the process is called "automation". The following is referred to as "early binding". It is the easiest, and most functional because it gives you access to Intellisense, but it is version-dependent. If you want version independence, you have to use "late binding". Add a reference to the Access type library Dim acc As Access.Application Dim db As DAO.Database Set acc = New Access.Application acc.OpenCurrentDatabase "path to database.mdb" Set db = acc.CurrentDb acc.Forms!frmMyForm!txtSomeTextbox = "abc" acc.Quit acQuitSaveNone acc.CloseCurrentDatabase Set db = Nothing Set acc = Nothing To use "late binding"... Dim acc As Object Dim db As DAO.Database Set acc = CreateObject("Access.Application") Regards, Graham R Seach Microsoft Access MVP Sydney, Australia --------------------------- "Jonathan" wrote in message ... Hello all, Is there any way for a VB application to communicate with an Access application via DDE? I want to be able to send text box data to Access forms, click buttons and menu bars from an external application. Thanks in advance, Jonathan |
#10
|
|||
|
|||
VB to Access via DDE
"Douglas J. Steele" wrote You don't click the button: you call the procedure (or macro) that's defined for the click event. Assuming the button is named MyButton, you'd do something like: Call acc.Forms("Form1").MyButton_Click Note that this requires that you change the declaration from Private Sub MyButton_Click() to Public Sub MyButton_Click(). In pure VB: Form1.MyButton.Value = True That command will cause the click event to execute. How does that fare in Access? Using the appropreate syntax for Access, would it have a similar effect? (No change to Public event needed....) LFS |
Thread Tools | |
Display Modes | |
|
|