Jump to content

Add row to table in Access97 then fill it in?


Falling
 Share

Recommended Posts

Hey i was just woundering if anyone here had experiance with using autoit to add rows to access97?

Example: I have a DB called SweetDB.

SweetDB has multiple Tables.

The tables i want to edit using Autoit are called tblCandy, tblSweets, tblWork

What I want autoit to do:

First a user will enter in all the information in a box.

0) password to the database (yes I know passwords on access97 are pointless)

1) password inside of tbl

2) Customer Name

3) Customer Location

4) Name of Bank

5) Name of Credit Card

After entering in this data Autoit will open tbleCandy

create a new row with a ID # that is 1 higher then the highest # in the table.

In that row it adds Customer Name, then skips 3 fields, adds password.

Then it will close tblCandy.

Next Autoit should open tblSweets create a new row with a ID # that is 1 higher then the highest # in tblSweets.

etc.

Anyone have advice on how to approch this problem? Thanks for any information.

Link to comment
Share on other sites

To start out you are going to have to get autoit to open your database. That is where you should start with your coding. Please get us some code that you either have some trouble with or want to verify, so you can move on to the next step.

After you get it open. You will then either script some keystrokes to open the right table, then have it enter the correct info, or use mouse clicks or winwaitactive() or something to open your tables for input.

Then you input what you want where you want.

First thing you need to check out either in helpfile or here in the forums is the Run() command. You will also need some information on @ComSpec (it has to do with the command prompt).

Get us some code and we will be more than happy to assist you on your way. I have a pretty decent database experience.

Thanks,

JS

AutoIt Links

File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out.

ComputerGetInfo UDF's Updated! 11-23-2006

External Links

Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)

Link to comment
Share on other sites

Well one problem I'm having is that Run() only works with (EXE, BAT, COM, or PIF) extensions and not .mdb. What i'm trying to work on at the moment is opening access97 then opening the file. Would be a lot nicer if Run() worked with all extensions.

When I try to run Access i get this:

Run("MSACCESS.EXE","C:\Program Files\97office\Office");

The system cannot find the file specified.

Edited by Falling
Link to comment
Share on other sites

I mentioned the @ComSpec because you can use it in Run to open other types of files. Check under macro's in the help file.

It also talks a bit about the @ComSpec in the Run() part of the help file.

Have you checked to make sure that is the exact link?

Maybe you should try the following...

Run("C:Program Files\97office\Office\MsAccess.exe", C:\Program Files\97office\Office")

Hope this helps a bit,

JS

AutoIt Links

File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out.

ComputerGetInfo UDF's Updated! 11-23-2006

External Links

Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)

Link to comment
Share on other sites

Does Access 97 support VBA (Visual Basic for Applications)?  If it does, then that is the way to go because that should get you much more tightly integrated to what you are trying to do than what AutoIt can.

<{POST_SNAPBACK}>

That is true that VBA would more tightly integrate, but he is wanting it to open and fill in his passwords and stuff. He could use autoit to that point then VBA after he gets it open and unlocked. Unless I am missing something from my VBA coding I dont think he can open and unlock a database from VBA that is in the database right?

Thanks,

JS

AutoIt Links

File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out.

ComputerGetInfo UDF's Updated! 11-23-2006

External Links

Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)

Link to comment
Share on other sites

Run("C:Program Files\97office\Office\MsAccess.exe", "C:\Program Files\97office\Office")

The system cannot find the file specified.

I read about @ComSpec --the help file does not seem to really go over it very well.

value of %comspec%, the SPECified secondary COMmand interpreter;

primarily for command line uses, e.g. Run(@ComSpec & " /k help | more")

--- Waaaa. How does it define itself by using itself?!

Link to comment
Share on other sites

so, use autoit to do the password, and vba to enter the data into the db... another idea, have autoit write the data to a text file, then have the db auto-import that data to the db when the db is opened?

"I'm not even supposed to be here today!" -Dante (Hicks)

Link to comment
Share on other sites

@Falling

Do not forget backslash!

<{POST_SNAPBACK}>

Haha wow...i guess i should not depend so much on Ctrl-C and Ctrl-V.

I'd much rather be able to just open the .mdb file though directly.

Is there somthing I'm not thinking about that would let you open it directly?

Edited by Falling
Link to comment
Share on other sites

I got this so far.

Run("C:\Program Files\97office\Office\MsAccess.exe", "C:\Program Files\97office\Office\")

WinWait("Microsoft Access");

ControlClick ( "Microsoft Access", "", "Button2")

This clicks Ok to open a "browse.." enviroment. So then I can browse to the correct spot.

Unfortunatly the folders in the browse menu do not show up as controls...how will i get to the directory with the dbs?

Link to comment
Share on other sites

Either:

A) Pass the file name as a parameter to Access to open the file.

B) Use @ComSpec and the start command to automatically trigger the extensions associated application.

C) Use _ShellExecute which you can find in the Scripts & Scraps forum.

Link to comment
Share on other sites

Run("C:\Program Files\97office\Office\MsAccess.exe", "C:\Program Files\97office\Office\")

WinWait("Microsoft Access");

ControlClick ( "Microsoft Access", "", "Button2")

sleep(3000)

ControlClick ( "Open", "", "OpenListView1")

Send("{DOWN}")

Send("{UP}")

Send("{ENTER}")

WinWait("Open");

ControlClick ( "Open", "", "OpenListView1")

Send("{DOWN}")

Send("{DOWN}")

Send("{DOWN}")

Send("{ENTER}")

WinWait("Password Required");

ControlClick ( "Open", "", "OpenListView1")

$password = "password"

Send($password)

Send("{ENTER}")

This gets me inside of my access db. It just seems so chunky. Wouold be cooler if i could of just went straight to the file and opened it?

Link to comment
Share on other sites

I'd much rather be able to just open the .mdb file though directly.

Is there somthing I'm not thinking about that would let you open it directly?

I do it all the time, try this:

Run(@ComSpec & " /c start mydatabase.mdb","",@SW_HIDE)

This is code for Win2000 and I think XP. If running other OS, I can change it for ya.

AutoIt3, the MACGYVER Pocket Knife for computers.

Link to comment
Share on other sites

I do it all the time, try this:

Run(@ComSpec & " /c start mydatabase.mdb","",@SW_HIDE)

This is code for Win2000 and I think XP. If running other OS, I can change it for ya.

<{POST_SNAPBACK}>

which will, by the way, have the same effect as running access with the file path... you're not going to get away from having to open the DB to input the info.

"I'm not even supposed to be here today!" -Dante (Hicks)

Link to comment
Share on other sites

I do it all the time, try this:

Run(@ComSpec & " /c start mydatabase.mdb","",@SW_HIDE)

This is code for Win2000 and I think XP. If running other OS, I can change it for ya.

<{POST_SNAPBACK}>

Scriptkiddy could you explain to me what @ComSpec is doing exactly?

does mydatabase.mdb have to be in my start menu??

.

I found this in scripts and scrapts: It works, unlike _shellexecute. It seems like a ton of code though if that @ComSpec works i'd rather use that.

Func _LaunchSomeThing($Path)
   $PathArray = StringSplit($Path,"\")
   $FileName = $PathArray[$PathArray[0]]
   $Dir = StringTrimRight($Path,StringLen($PathArray[$PathArray[0]]) + 1)  
   If StringRight($Dir,1) = "\" Then $Dir = StringTrimRight($Dir,1)
   Run("explorer " & $Dir,"",@SW_MINIMIZE)
   $ExpClass = "classname=CabinetWClass|classname=ExploreWClass"
   $ExpClassArray = StringSplit($ExpClass,"|")
   For $i = 1 To $ExpClassArray[0]
      While 1
         If WinExists($ExpClassArray[$i]) Then ExitLoop(2)
         Sleep(10)
      Wend
   Next
   WinWait($ExpClassArray[$i],$Dir)
   $ExpHandle = WinGetHandle($ExpClassArray[$i],$Dir)
   ControlFocus($ExpClassArray[$i],$Dir,"SysListView321")
   ControlSend($ExpClassArray[$i],$Dir,"SysListView321",$Filename)
   ControlSend($ExpClassArray[$i],$Dir,"SysListView321","{ENTER}")
   WinClose($ExpHandle,$Path)
EndFunc
Link to comment
Share on other sites

Why does it say my password is wrong in Access??

#include "launch.au3"

sleep(500)

_LaunchSomeThing("C:\Documents and Settings\charles\My Documents\autotest\ServerDB.mdb")

WinWait("Password Required")

$password = String("1$2()!xymA")

Send($password)

sleep(1500)

Send("{ENTER}"

This is not my real password mine is a lot longer but uses similar symbols/letters

For some reason if i type it manually it works but if I use Send($password) it says the password is incorrect.

Link to comment
Share on other sites

As far as that goes...

$password = "1$2()!xymA"

I do not see a reason to put the String() around it.

Are you still interested in the @ComSpec? I am assuming not since you have already gone ahead with that script you found.

Hope this helps,

JS

AutoIt Links

File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out.

ComputerGetInfo UDF's Updated! 11-23-2006

External Links

Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...