Beefy Boxes and Bandwidth Generously Provided by pair Networks Frank
Think about Loose Coupling
 
PerlMonks  

Problem to open form in Access

by x-lours (Novice)
on Jun 29, 2012 at 12:52 UTC ( #979120=perlquestion: print w/ replies, xml ) Need Help??
x-lours has asked for the wisdom of the Perl Monks concerning the following question:

Hello everybody, i try to open a form in Access by using Win32::OLE. here is my code :

$access_obj = Win32::OLE->new('Access.Application') or die "utilisatio +n_ACCESS:Oops, cannot start Access"; $access_obj->OpenCurrentDatabase($source_access) ; $access_obj->{'Visible'} = 1; # ouverture du formulaire de l'ACCESS $access_obj->DoCmd->OpenForm('Formulaire1') or warn "Impossible d'ouvr +ir le formulaire:$!\n"; # fermeture de l'ACCESS $access_obj->Quit();

i copy it from "http://www.perlmonks.org/?node_id=762359" but i get the message "Impossible d'ouvrir le formulaire:No such file or directory" ! (the warning) and can't explain why. the name is correct. i try to replace ' by " and it does the same ... any help please ? ;-)

Comment on Problem to open form in Access
Download Code
Re: Problem to open form in Access
by Anonymous Monk on Jun 29, 2012 at 13:20 UTC

    and can't explain why. the name is correct. i

    What does the documenation for OpenForm say? I doubt it sets errno on error

    I prefer to use  or die sprintf q/ERRRR(%d)(%s)(%d)(%s)/, $!,$!,$^E,$^E;

      with tour modification i get :

      ERRRR(2)(No such file or directory)(0)() at lancer_TU_version14.pl line 1313.

      i didn't find the document for OpenForm... still searching

        ERRRR(2)(No such file or directory)(0)() at lancer_TU_version14.pl line 1313.

        That means you shouldn't be checking $! because OpenForm doesn't use errno for signaling errors

        i didn't find the document for OpenForm... still searching

        Where are you searching?

        Took me all of 5 seconds to type ddg://site:msdn.microsoft.com Access OpenForm

Re: Problem to open form in Access
by kcott (Abbot) on Jun 29, 2012 at 16:23 UTC

    Your error message consists of two concatenated strings:

    1. Impossible d'ouvrir le formulaire: - You wrote this, so it would appear that $access_obj->DoCmd->OpenForm('Formulaire1') was not successful. As you used warn, your code continued but possibly with bogus -- undefined, empty, etc. -- data.
    2. You also wrote $! which interpolated as "No such file or directory". This error is often resolved by supplying a relative ../Formulaire1 or absolute /some/path/to/Formulaire1 pathname. Furthermore, your OS may ignore filename extensions then act dumb when you supply it with exactly the same filename strings that it supplies to you: you may need to specify Formulaire1 as Formulaire1.XXX (where XXX is the hidden extension).

    -- Ken

      Furthermore, your OS may ignore filename extensions
      Worst. Default. Ever.

      thanks for advices.

      1. i do 'warn' instead of 'die' because i want access to close normally, further lines later.

      2. the form 'formulaire1' is inside access so i can't imagine the path for it. i try ./formulaire1 and obtain :

      OLE exception from "<Unknown Source>": Le nom de formulaire './Formulaire1' entré dans la feuille des propriétés ou dans une macro est mal orthographié ou fait référence à un formulaire inexistant. Win32::OLE(0.1709) error 0x800a0836 in METHOD/PROPERTYGET "OpenForm" at lancer_TU_version14.pl line 1312 Impossible d'ouvrir le formulaire:No such file or directory

      obviously, if i search for it, i didn't find the form 'formulaire1' in the OS files.
        i added my $var = <STDIN>; to see my messages, and i discover that the form was open !!!

        i try to get the value of the $access_obj->DoCmd->OpenForm('Formulaire1'); it is null (undef). that is why i get the warning message ...

        so the post can be closed. (how ?)

        Access application doesn't return a value for this call, and a 'action to wait' is needed.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://979120]
Approved by toolic
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (6)
As of 2014-04-24 10:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (565 votes), past polls