Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Microsoft Access script help  (Read 2557 times)

0 Members and 1 Guest are viewing this topic.

coppaj

    Topic Starter


    Newbie

    • Experience: Beginner
    • OS: Unknown
    Microsoft Access script help
    « on: May 25, 2011, 07:55:23 AM »
    I have a microsoft access database for computer inventory.

    I would like to add a button that when clicked, will open a remote desktop session (RDP) to connect the computer that we are looking at.

    We have a batch file that might help with this code intergration.

    TITLE Brett's Remote Connection Tool
    mode con:cols=100 lines=50
    @color E
    @echo off
    REM   This is the main menu of the program.
    goto menu
    :menu
    echo Brett's Remote Connection tool v1.0
    echo.
    echo.
    echo This program will remotely connect to the PC of your choice.
    echo.
    echo  ______________________________
    echo !                              !
    echo !  1. Connect to laptop       !
    echo !  2. Connect to desktop       !
    echo !  3. Freeform entry           !
    echo !  4. Exit             !
    echo !                    !
    echo !______________________________!
    echo.

    REM   This establishes what part of the file each user input will correspond to.
    :choice
    set /P C=Enter Selection #:
    if "%C%"=="4" goto quit
    if "%C%"=="3" goto freeform
    if "%C%"=="2" goto desktop
    if "%C%"=="1" goto laptop
    goto choice



    :desktop
    set /p D=Type the desktop number:
    start mstsc /v:MAX42MGWK%D% /w:640 /h:480
    goto menu

    :laptop
    set /p L=Type the laptop number:
    start mstsc /v:MAX42MGLP%L% /w:640 /h:480
    goto menu

    :freeform
    set /p F=Type the entire PC name:
    start mstsc /v:%F% /w:640 /h:480
    goto menu

    :quit
    exit
    :end

    Geek-9pm


      Mastermind
    • Geek After Dark
    • Thanked: 1026
      • Gekk9pm bnlog
    • Certifications: List
    • Computer: Specs
    • Experience: Expert
    • OS: Windows 10
    Re: Microsoft Access script help
    « Reply #1 on: May 25, 2011, 08:28:32 AM »
    This is way over my head.
    May I ask if  you have done a Google for other forums that are more specific to your project. That's a rhetorical question. Of course you have.
    You would have used these keywords:
    Microsoft Access
    remote desktop
    menu script
    You would have come across  sites named  freelancer.
    Still, let me ask:
    Have you looked at
    http://freelancer.com
    or
    http://freelancer.com.au
    to see what projects they have like yours? They have both twitter and facebook links, so maybe you can find some free advice.
    Just a thought. And no, I do not work for them. Wish I did.

    soybean



      Genius
    • The first soybean ever to learn the computer.
    • Thanked: 469
    • Computer: Specs
    • Experience: Experienced
    • OS: Windows 10
    Re: Microsoft Access script help
    « Reply #2 on: May 25, 2011, 03:26:44 PM »
    Since we don't have members who are well-versed in Access, as far as I know, I'm going to take the liberty to suggest an Access-specific forum.  It's http://www.accessforums.net/ 

    BC_Programmer


      Mastermind
    • Typing is no substitute for thinking.
    • Thanked: 1140
      • Yes
      • Yes
      • BC-Programming.com
    • Certifications: List
    • Computer: Specs
    • Experience: Beginner
    • OS: Windows 11
    Re: Microsoft Access script help
    « Reply #3 on: May 25, 2011, 04:02:54 PM »
    Two problems:

    You mention nothing about how your form is laid out
    You mention nothing about your table and field layout.


    Since Access is just VBA, you can just use the shell() function from within the Button Click event of a form in access.

    Without knowledge of your database schema, I created my own to serve as an example.

    It consists of a single table, tblComputers, which merely lists two computer names (Field:Compname), as well as some otherwise useless satellite data (the type of the machine, laptop or desktop) (field:Type). I added two entries to the table corresponding to my two machines, record navigation buttons, that type of stuff.

    The important bit is the "connect" button I added. The code simply runs "Shell":

    Code: [Select]
    Private Sub Detail_Click()
    Shell "mstsc /v:" + CompName.Text + " /w:640 /h:480"
    End Sub


    Presumably, your database scheme also includes whether they are a desktop or a laptop; (based on the content of the batch file) in which case you could build the computer name to use like so:

    Code: [Select]
    Private Function GetConnectName() as String
    if MachineType.Text="Desktop" Then
        GetConnectName="MAX42MGWK" + DesktopNumber.Text
    Else
        GetConnectName="MAX42MGLP" + LaptopNumber.Text
    End If

    End Function



    and then the Click event becomes:

    Code: [Select]
    Private Sub Detail_Click()
    Shell "mstsc /v:" + GetConnectName() + " /w:640 /h:480"
    End Sub


    Without more info on your database schema/form setup, I can't really provide anything more specific than that.


    I was trying to dereference Null Pointers before it was cool.