Re: Need to start mdb using Startup command-line options and pass in a parameter

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



If you're passing that many parameters, it could be the problem....i.e.,
there is might a limit in respect to length. Nevertheless, if your command
line parameters were a reasonable length, you'd pass them like this

msaccess.exe /cmd Parm1|Parm2|Parm3|Etc

Then in the startup code for the database you would parse the Command
function....which would contain.

Parm1|Parm2|Parm3|Etc

If that doesn't work for for your needs, you might try using automation to
start Access and open the database...then pass the parameters to fields on a
hidden form...then execute some method within that form to do whatever it is
you need to do and close the form. Air code follows...

Set objAccess = CreateObject("Access.Application")
objAccess.OpenCurrentDatabase "path to file"
objAccess.Docmd.OpenForm "someform",,,,,acHidden
Set frm = objAccess.Forms("someform")
frm.txtField1 = Parm1
etc..

frm.DoSomething

BTW...you might want to be careful how you phrase comments...you sorta
implied that I/others don't know anything? Keep in mind that you are asking
for VB.Net help in a Access NG....so, translating Access VBA code really
falls to you.
--
Paul Overway
Logico Solutions
http://www.logico-solutions.com


"moondaddy" <moondaddy@xxxxxxxxxxxxx> wrote in message
news:%23Mz3Ku%23aFHA.612@xxxxxxxxxxxxxxxxxxxxxxx
> Thanks but I've read the documentation on command and startup command in
> to .net and access and there's no mention of passing in the parameter that
> my function in access is expecting. only parameters for the command line
> switches. It would be nice if someone who knows something about this
> could show an example of how it would work.
>
> I found a work around to make things work, but its a bit of a hack to say
> the least, but it WORKS.
>
> code in vb.net:
>
>
> 'Build the mdb path and access exe path and add on a switch to run a
> macro in access. this macro will then call my function in a module.
> stAppName = """C:\Program Files\Microsoft Office\OFFICE11\MSACCESS.EXE"" "
> & _
> """D:\nwis\Apps\LandMan\VS\TransAct\TransAct\Stallion\TransAct_Stallion_Remote.mdb"""
> & "/x mcrStartupGroup.mcrStartApp"
>
> 'now execute the command in the .net app.
> Dim ID As Int32 = Shell(stAppName, AppWinStyle.NormalFocus, False, -1)
>
> Now the HACK. In the .net app just before these lines execute I created a
> text file which contains a text string with about 15 parameters comma
> delimited. Code above executes and the function in access is called. The
> function in Access opens this text file and reads the string, parses out
> the parameters, closes the text file and then deletes it so in all it only
> exists for a split second. lastly, access has its parameters to start
> running the app.
> whew.
>
>
>
> --
> moondaddy@xxxxxxxxxxxxx
> "Paul Overway" <paul@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
> news:uEdzhP7aFHA.1312@xxxxxxxxxxxxxxxxxxxxxxx
>> First, you need to shell with the /cmd switch and your parameters. Then
>> within the MDB, you have to parse the Command function. See help for
>> Command.
>>
>> --
>> Paul Overway
>> Logico Solutions
>> http://www.logico-solutions.com
>>
>>
>> "moondaddy" <moondaddy@xxxxxxxxxxxxx> wrote in message
>> news:ONBzHF7aFHA.2696@xxxxxxxxxxxxxxxxxxxxxxx
>>> Thats the first place I went, but saw no mention of passing in
>>> parameters to a macro or function. Any more advice?
>>>
>>> --
>>> moondaddy@xxxxxxxxxxxxx
>>> "Marshall Barton" <marshbarton@xxxxxxxxxx> wrote in message
>>> news:uh2ca1d3c1oqr11mqf0kveqc19h7j9a84j@xxxxxxxxxx
>>>> moondaddy wrote:
>>>>
>>>>>from a .net winforms application I need to start a MS Access 2003
>>>>>application using the startup command-line and shell. I can start the
>>>>>application OK, but need to call a public function or a macro that will
>>>>>call
>>>>>the function and pass in a parameter string. how can I do this and
>>>>>what's
>>>>>the syntax?
>>>>>
>>>>>Dim Param As String = "Bla1, bla2, bla3"
>>>>>Dim FuncName As String = "myStartupFunc"
>>>>>Dim stAppName As String
>>>>>stAppName = """C:\Program Files\Microsoft
>>>>>Office\OFFICE11\MSACCESS.EXE"" " &
>>>>>_
>>>>>"""D:\nwis\Apps\LandMan\VS\TransAct\TransAct\Stallion\TransAct_Stallion_Remote.mdb"""
>>>>>
>>>>>'This line works good for opening the app
>>>>>Dim ID As Int32 = Shell(stAppName, AppWinStyle.NormalFocus, False, -1)
>>>>>
>>>>>But how do I change it to call myStartupFunc and pass Param into
>>>>>myStartupFunc?
>>>>>
>>>>>Using the interop libraries in .net are not a good option do to
>>>>>complications involved in installing on lots of remote computers,
>>>>>licensing,
>>>>>etc. We've had lots of problems with it and both MS and InstallShield
>>>>>are
>>>>>stumped. Using the shell command would be way cleaner and less error
>>>>>prone.
>>>>
>>>>
>>>> Check Access Help for Startup command-line options,
>>>> especially
>>>> /X macro
>>>> and
>>>> /cmd
>>>>
>>>> --
>>>> Marsh
>>>> MVP [MS Access]
>>>
>>>
>>
>>
>
>


.



Relevant Pages

  • Re: parsing a response line from sysfiletree
    ... Parse value subwordsubword ... This comes from using a machine with dots as the 'directory' separator a lot ... File$Type_C85 has value "JPEG" ... to find the command to be used to 'run' a jpeg. ...
    (comp.lang.rexx)
  • Re: OptionParser Question
    ... -- BTR ... I'm using OptionParser to parse command line options. ... puts "The arguments are #" ...
    (comp.lang.ruby)
  • Re: special variable $? usage
    ... have to do with the numbers output from "runmqsc ... Perhaps he really wants to read and parse the output from the ... # Open input pipe from command line. ... This is similar to piping the command to your program and reading from STDIN. ...
    (perl.beginners)
  • Re: Parsing a bash string?
    ... seguso wrote in message news: ... > I have to be able to parse a command line typed by the user. ... > I.e., I need a function that, when given a typical bash command string like ...
    (comp.unix.shell)
  • Re: Retrieve most recent file
    ... command to loop through and parse the version number out so you can ... retrieve the file "...\CAMTA_be Vxx Ryy.mdb" where xx and yy would be the ...
    (microsoft.public.access.modulesdaovba)