How to set the current record in a Microsoft Access form from external program -


the background: charity work has 2 systems, new c# system , ms access system. taking phone call means looking them on new system, looking them second time on legacy system. unfortunately we're stuck access system, because don't have money re-develop it.

both systems use unique personid each person, , ids synchronised between systems. access system 1 giant form shows info particular personid.

the problem: want tell access move current record particular personid external c# program. i don't want launch new access window, slow on our pcs.

i've tried think google control access outside (something dde??) i'm drawing blank. can give me pointers for? possible?

you can use com automation. if new system e.g. excel, use vba code this:

sub testcomtoaccess()      ' has references microsoft access object library & microsoft dao 3.6 object library      dim oaccess access.application     dim oform access.form     dim rs dao.recordset      ' assumes 1 instance of access running, old application     set oaccess = getobject(, "access.application")     set oform = oaccess.forms("your_giant_form")      ' find record looking     set rs = oform.recordsetclone     rs.findfirst "myprimarykey = 42"     ' , navigate form record     if not rs.nomatch         oform.bookmark = rs.bookmark     end if     rs.close  end sub 

and according how interact programs ole automation in c#? adapted c# , .net.

for c# windows forms application, equivalent code be:

using system; using system.windows.forms;  namespace comautowindowsformsapp {     public partial class mycsharpform : form     {         microsoft.office.interop.access.application accapp;         public mycsharpform()         {             initializecomponent();         }          private void mycsharpform_load(object sender, eventargs e)         {             accapp =                  (microsoft.office.interop.access.application)                  system.runtime.interopservices.marshal.getactiveobject("access.application");         }          private void button1_click(object sender, eventargs e)         {             microsoft.office.interop.access.form accform = accapp.forms["your_giant_form"];             microsoft.office.interop.access.dao.recordset accrs = accform.recordsetclone;             accrs.findfirst("myprimarykey = 42");             if (!accrs.nomatch)             {                 accform.bookmark = accrs.get_bookmark();             }             accrs.close();         }     } } 

Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -