Jump to content
Sign in to follow this  
nerdgerl

MS Access (Style) Database

Recommended Posts

nerdgerl

CODE
#include <string.au3>

#include <INet.au3>

#Include <Array.au3>

#include <File.au3>

#include <GUIConstants.au3>

; ======================================= Default Settings =======================================

Dim $RecordNo = 1

Dim $inifile = "database.ini"

; ======================================= Hot Keys =======================================

HotKeySet("^e", "Email")

HotKeySet("^h", "Home")

HotKeySet("^w", "Work")

;HotKeySet("{F1}", "Help")

; ======================================= Main Interface =======================================

$Form1 = GUICreate("Worker-Base", 459, 380, -1, -1)

GUISetIcon("database.ico")

; ======================================= Menubar =======================================

$filemenu = GUICtrlCreateMenu("&File")

$filenewitem = GUICtrlCreateMenuitem("&New", $filemenu)

$fileopenitem = GUICtrlCreateMenuitem("&Open", $filemenu)

$filesaveasitem = GUICtrlCreateMenuitem("&Save As...", $filemenu)

$MenuSeparator = GUICtrlCreateMenuitem("", $filemenu)

$fileexportitem = GUICtrlCreateMenuitem("&Export", $filemenu)

$fileprintitem = GUICtrlCreateMenuitem("&Print", $filemenu)

$MenuSeparator = GUICtrlCreateMenuitem("", $filemenu)

$fileexititem = GUICtrlCreateMenuitem("E&xit", $filemenu)

$editmenu = GUICtrlCreateMenu("&Edit")

$editcutitem = GUICtrlCreateMenuitem("&Cut", $editmenu)

$editcopyitem = GUICtrlCreateMenuitem("C&opy", $editmenu)

$editpasteitem = GUICtrlCreateMenuitem("&Paste", $editmenu)

$MenuSeparator = GUICtrlCreateMenuitem("", $editmenu)

$editgotoitem = GUICtrlCreateMenuitem("&Go To Record", $editmenu)

$editfinditem = GUICtrlCreateMenuitem("&Find Record", $editmenu)

$editdeleteitem = GUICtrlCreateMenuitem("&Delete Record", $editmenu)

$helpmenu = GUICtrlCreateMenu("&Help")

$helpaboutitem = GUICtrlCreateMenuitem("&About", $helpmenu)

$Separator = GUICtrlCreateGraphic(0, 0, 455, 1, $SS_ETCHEDFRAME)

; ======================================= Database Fields =======================================

$Label1 = GUICtrlCreateLabel("WorkID:", 16, 16, 41, 17)

$WorkID = GUICtrlCreateInput("", 16, 32, 49, 21)

$Label6 = GUICtrlCreateLabel("Title:", 72, 16, 24, 17)

$Title = GUICtrlCreateInput("", 72, 32, 73, 21)

$Label3 = GUICtrlCreateLabel("First Name:", 152, 16, 54, 17)

$FirstName = GUICtrlCreateInput("", 152, 32, 89, 21)

$Label5 = GUICtrlCreateLabel("Middle Name:", 248, 16, 66, 17)

$MiddleName = GUICtrlCreateInput("", 248, 32, 89, 21)

$Label4 = GUICtrlCreateLabel("Last Name:", 344, 16, 55, 17)

$LastName = GUICtrlCreateInput("", 344, 32, 89, 21)

$Label7 = GUICtrlCreateLabel("Email Address:", 28, 68, 70, 17)

$EmailAddress = GUICtrlCreateInput("", 104, 64, 121, 21)

$Label8 = GUICtrlCreateLabel("Home Address:", 24, 93, 73, 17)

$HomeAddress = GUICtrlCreateInput("", 104, 88, 121, 21)

$Label9 = GUICtrlCreateLabel("City:", 75, 116, 21, 17)

$City = GUICtrlCreateInput("", 104, 112, 121, 21)

$Label10 = GUICtrlCreateLabel("State:", 67, 139, 29, 17)

$State = GUICtrlCreateInput("", 104, 136, 121, 21)

$Label11 = GUICtrlCreateLabel("Zip Code:", 48, 164, 47, 17)

$ZipCode = GUICtrlCreateInput("", 104, 160, 121, 21)

$Label12 = GUICtrlCreateLabel("Country:", 56, 189, 40, 17)

$Country = GUICtrlCreateInput("", 104, 184, 121, 21)

$Label13 = GUICtrlCreateLabel("Home Phone:", 31, 211, 66, 17)

$HomePhone = GUICtrlCreateInput("", 104, 208, 121, 21)

$Label14 = GUICtrlCreateLabel("Work Phone:", 32, 236, 64, 17)

$WorkPhone = GUICtrlCreateInput("", 104, 232, 121, 21)

$Label22 = GUICtrlCreateLabel("SSN#:", 272, 68, 36, 17)

$SSN = GUICtrlCreateInput("", 312, 64, 121, 21)

$Label23 = GUICtrlCreateLabel("Work No:", 256, 93, 50, 17)

$WorkNo = GUICtrlCreateInput("", 312, 88, 121, 21)

$Label17 = GUICtrlCreateLabel("Hire Date:", 254, 116, 49, 17)

$HireDate = GUICtrlCreateInput("", 312, 112, 121, 21)

$Label18 = GUICtrlCreateLabel("Hourly Salary:", 237, 139, 66, 17)

$Salary = GUICtrlCreateInput("", 312, 136, 121, 21)

$Label19 = GUICtrlCreateLabel("Billing Rate:", 245, 164, 57, 17)

$BillingRate = GUICtrlCreateInput("", 312, 160, 121, 21)

$Label20 = GUICtrlCreateLabel("Deductions:", 245, 189, 58, 17)

$Deductions = GUICtrlCreateInput("", 312, 184, 121, 21)

$Label2 = GUICtrlCreateLabel("Department:", 245, 211, 59, 17)

$Department = GUICtrlCreateInput("", 312, 208, 121, 21)

$Label21 = GUICtrlCreateLabel("Supervisor:", 249, 236, 54, 17)

$Supervisor = GUICtrlCreateInput("", 312, 232, 121, 21)

$Label15 = GUICtrlCreateLabel("Emergency Contact Name:", 139, 269, 128, 17)

$EmergencyContactName = GUICtrlCreateInput("", 272, 264, 161, 21)

$Label16 = GUICtrlCreateLabel("Emergency Contact Phone:", 136, 292, 131, 17)

$EmergencyContactPhone = GUICtrlCreateInput("", 272, 288, 161, 21)

$Separator = GUICtrlCreateGraphic(1, 321, 455, 1, $SS_ETCHEDFRAME)

; ======================================= Nagivation =======================================

$First = GUICtrlCreateButton("7", 7, 330, 18, 21, 0)

GUICtrlSetFont(-1, 8, 400, 0, "Webdings")

$Previous = GUICtrlCreateButton("3", 25, 330, 18, 21, 0)

GUICtrlSetFont(-1, 8, 400, 0, "Webdings")

$RecordNumber = GUICtrlCreateInput("1", 43, 330, 83, 21)

$Next = GUICtrlCreateButton("4", 126, 330, 18, 21, 0)

GUICtrlSetFont(-1, 8, 400, 0, "Webdings")

$Last = GUICtrlCreateButton("8", 144, 330, 18, 21, 0)

GUICtrlSetFont(-1, 8, 400, 0, "Webdings")

If GUICtrlRead($WorkID) = "" Then

GUICtrlSetData($WorkID, $RecordNo)

EndIf

If Not FileExists("database.ini") Then

FileWrite("database.ini", "")

IniWrite($inifile, GUICtrlRead($RecordNumber), "WorkID", "1")

IniWrite($inifile, GUICtrlRead($RecordNumber), "Title", GUICtrlRead($Title))

IniWrite($inifile, GUICtrlRead($RecordNumber), "FirstName", GUICtrlRead($FirstName))

IniWrite($inifile, GUICtrlRead($RecordNumber), "MiddleName", GUICtrlRead($MiddleName))

IniWrite($inifile, GUICtrlRead($RecordNumber), "LastName", GUICtrlRead($LastName))

IniWrite($inifile, GUICtrlRead($RecordNumber), "EmailAddress", GUICtrlRead($EmailAddress))

IniWrite($inifile, GUICtrlRead($RecordNumber), "HomeAddress", GUICtrlRead($HomeAddress))

IniWrite($inifile, GUICtrlRead($RecordNumber), "City", GUICtrlRead($City))

IniWrite($inifile, GUICtrlRead($RecordNumber), "State", GUICtrlRead($State))

IniWrite($inifile, GUICtrlRead($RecordNumber), "ZipCode", GUICtrlRead($ZipCode))

IniWrite($inifile, GUICtrlRead($RecordNumber), "Country", GUICtrlRead($Country))

IniWrite($inifile, GUICtrlRead($RecordNumber), "HomePhone", GUICtrlRead($HomePhone))

IniWrite($inifile, GUICtrlRead($RecordNumber), "WorkPhone", GUICtrlRead($WorkPhone))

IniWrite($inifile, GUICtrlRead($RecordNumber), "SSN", GUICtrlRead($SSN))

IniWrite($inifile, GUICtrlRead($RecordNumber), "WorkNo", GUICtrlRead($WorkNo))

IniWrite($inifile, GUICtrlRead($RecordNumber), "HireDate", GUICtrlRead($HireDate))

IniWrite($inifile, GUICtrlRead($RecordNumber), "Salary", GUICtrlRead($Salary))

IniWrite($inifile, GUICtrlRead($RecordNumber), "BillingRate", GUICtrlRead($BillingRate))

IniWrite($inifile, GUICtrlRead($RecordNumber), "Deductions", GUICtrlRead($Deductions))

IniWrite($inifile, GUICtrlRead($RecordNumber), "Department", GUICtrlRead($Department))

IniWrite($inifile, GUICtrlRead($RecordNumber), "Supervisor", GUICtrlRead($Supervisor))

IniWrite($inifile, GUICtrlRead($RecordNumber), "EmergencyContactName", GUICtrlRead($EmergencyContactName))

IniWrite($inifile, GUICtrlRead($RecordNumber), "EmergencyContactPhone", GUICtrlRead($EmergencyContactPhone))

GUICtrlSetData($WorkID, $RecordNo)

EndIf

GUISetState()

LoadData()

While 1

$msg = GUIGetMsg()

Select

Case $msg = $GUI_EVENT_CLOSE

Exit

; ======================================= File Menu Functions =======================================

Case $msg = $fileexititem

Exit

Case $msg = $fileprintitem

PrintDatabase()

Case $msg = $fileexportitem

ExportDatabase()

Case $msg = $filenewitem

NewDatabase()

Case $msg = $fileopenitem

OpenDatabase()

Case $msg = $filesaveasitem

SaveAsDatabase()

; ======================================= Navigation Functions =======================================

Case $msg = $First

SaveData()

$RecordNo = 1

LoadData()

Case $msg = $Previous

SaveData()

$RecordNo = (GUICtrlRead($RecordNumber) - 1)

If $RecordNo > 0 Then

LoadData()

Else

;Do Nothing

EndIf

Case $msg = $Next

SaveData()

$RecordNo = (GUICtrlRead($RecordNumber) + 1)

If $RecordNo < 211 Then

LoadData()

If GUICtrlRead($WorkID) = "" Then

GUICtrlSetData($WorkID, $RecordNo)

EndIf

Else

;Do Nothing

EndIf

Case $msg = $Last

SaveData()

$LastRecord = _ReplaceStringInFile($inifile, "$WorkID", "$WorkID")

$RecordNo = $LastRecord

If $RecordNo > 0 And $RecordNo < 211 Then

LoadData()

Else

;Do Nothing

EndIf

; ======================================= Edit Menu Functions =======================================

Case $msg = $editcutitem

Send("^x")

Case $msg = $editcopyitem

Send("^c")

Case $msg = $editpasteitem

Send("^v")

Case $msg = $editfinditem

;Prepare for total record count and search

FindRecord()

Case $msg = $editdeleteitem

IniDelete($inifile, GUICtrlRead($RecordNumber))

$RecordNo = (GUICtrlRead($RecordNumber) + 1)

If $RecordNo < 211 Then

LoadData()

If GUICtrlRead($WorkID) = "" Then

GUICtrlSetData($WorkID, $RecordNo)

EndIf

Else

;Do Nothing

EndIf

SaveData()

MsgBox(0, "Status", "Record Deleted")

Case $msg = $editgotoitem

GoToRecord()

; ======================================= Help Menu Functions =======================================

Case $msg = $helpaboutitem

About()

EndSelect

WEnd

Func LoadData()

GUICtrlSetData($RecordNumber, $RecordNo)

GUICtrlSetData($BillingRate, IniRead($inifile, GUICtrlRead($RecordNumber), "BillingRate", ""))

GUICtrlSetData($City, IniRead($inifile, GUICtrlRead($RecordNumber), "City", ""))

GUICtrlSetData($Country, IniRead($inifile, GUICtrlRead($RecordNumber), "Country", ""))

GUICtrlSetData($Deductions, IniRead($inifile, GUICtrlRead($RecordNumber), "Deductions", ""))

GUICtrlSetData($Department, IniRead($inifile, GUICtrlRead($RecordNumber), "Department", ""))

GUICtrlSetData($EmailAddress, IniRead($inifile, GUICtrlRead($RecordNumber), "EmailAddress", ""))

GUICtrlSetData($EmergencyContactName, IniRead($inifile, GUICtrlRead($RecordNumber), "EmergencyContactName", ""))

GUICtrlSetData($EmergencyContactPhone, IniRead($inifile, GUICtrlRead($RecordNumber), "EmergencyContactPhone", ""))

GUICtrlSetData($FirstName, IniRead($inifile, GUICtrlRead($RecordNumber), "FirstName", ""))

GUICtrlSetData($HireDate, IniRead($inifile, GUICtrlRead($RecordNumber), "HireDate", ""))

GUICtrlSetData($HomeAddress, IniRead($inifile, GUICtrlRead($RecordNumber), "HomeAddress", ""))

GUICtrlSetData($HomePhone, IniRead($inifile, GUICtrlRead($RecordNumber), "HomePhone", ""))

GUICtrlSetData($LastName, IniRead($inifile, GUICtrlRead($RecordNumber), "LastName", ""))

GUICtrlSetData($MiddleName, IniRead($inifile, GUICtrlRead($RecordNumber), "MiddleName", ""))

GUICtrlSetData($Salary, IniRead($inifile, GUICtrlRead($RecordNumber), "Salary", ""))

GUICtrlSetData($SSN, IniRead($inifile, GUICtrlRead($RecordNumber), "SSN", ""))

GUICtrlSetData($State, IniRead($inifile, GUICtrlRead($RecordNumber), "State", ""))

GUICtrlSetData($Supervisor, IniRead($inifile, GUICtrlRead($RecordNumber), "Supervisor", ""))

GUICtrlSetData($Title, IniRead($inifile, GUICtrlRead($RecordNumber), "Title", ""))

GUICtrlSetData($WorkID, IniRead($inifile, GUICtrlRead($RecordNumber), "WorkID", ""))

GUICtrlSetData($WorkNo, IniRead($inifile, GUICtrlRead($RecordNumber), "WorkNo", ""))

GUICtrlSetData($WorkPhone, IniRead($inifile, GUICtrlRead($RecordNumber), "WorkPhone", ""))

GUICtrlSetData($ZipCode, IniRead($inifile, GUICtrlRead($RecordNumber), "ZipCode", ""))

EndFunc ;==>LoadData

Func SaveData()

IniWrite($inifile, GUICtrlRead($RecordNumber), "BillingRate", GUICtrlRead($BillingRate))

IniWrite($inifile, GUICtrlRead($RecordNumber), "City", GUICtrlRead($City))

IniWrite($inifile, GUICtrlRead($RecordNumber), "Country", GUICtrlRead($Country))

IniWrite($inifile, GUICtrlRead($RecordNumber), "Deductions", GUICtrlRead($Deductions))

IniWrite($inifile, GUICtrlRead($RecordNumber), "Department", GUICtrlRead($Department))

IniWrite($inifile, GUICtrlRead($RecordNumber), "EmailAddress", GUICtrlRead($EmailAddress))

IniWrite($inifile, GUICtrlRead($RecordNumber), "EmergencyContactName", GUICtrlRead($EmergencyContactName))

IniWrite($inifile, GUICtrlRead($RecordNumber), "EmergencyContactPhone", GUICtrlRead($EmergencyContactPhone))

IniWrite($inifile, GUICtrlRead($RecordNumber), "FirstName", GUICtrlRead($FirstName))

IniWrite($inifile, GUICtrlRead($RecordNumber), "HireDate", GUICtrlRead($HireDate))

IniWrite($inifile, GUICtrlRead($RecordNumber), "HomeAddress", GUICtrlRead($HomeAddress))

IniWrite($inifile, GUICtrlRead($RecordNumber), "HomePhone", GUICtrlRead($HomePhone))

IniWrite($inifile, GUICtrlRead($RecordNumber), "LastName", GUICtrlRead($LastName))

IniWrite($inifile, GUICtrlRead($RecordNumber), "MiddleName", GUICtrlRead($MiddleName))

IniWrite($inifile, GUICtrlRead($RecordNumber), "Salary", GUICtrlRead($Salary))

IniWrite($inifile, GUICtrlRead($RecordNumber), "SSN", GUICtrlRead($SSN))

IniWrite($inifile, GUICtrlRead($RecordNumber), "State", GUICtrlRead($State))

IniWrite($inifile, GUICtrlRead($RecordNumber), "Supervisor", GUICtrlRead($Supervisor))

IniWrite($inifile, GUICtrlRead($RecordNumber), "Title", GUICtrlRead($Title))

IniWrite($inifile, GUICtrlRead($RecordNumber), "WorkID", GUICtrlRead($WorkID))

IniWrite($inifile, GUICtrlRead($RecordNumber), "WorkNo", GUICtrlRead($WorkNo))

IniWrite($inifile, GUICtrlRead($RecordNumber), "WorkPhone", GUICtrlRead($WorkPhone))

IniWrite($inifile, GUICtrlRead($RecordNumber), "ZipCode", GUICtrlRead($ZipCode))

EndFunc ;==>SaveData

Func FindRecord()

;Get search term

$FindRecordForm = GUICreate("Find Record", 255, 71, 450, 327)

GUISetIcon("database.ico")

$FindRecordLabel = GUICtrlCreateLabel("Criteria:", 5, 4, 39, 17)

$FindRecordInput = GUICtrlCreateInput("", 4, 22, 246, 21)

$FindRecordButton = GUICtrlCreateButton("Find", 185, 47, 64, 19, $BS_DEFPUSHBUTTON)

GUISetState(@SW_SHOW)

While 1

$FindRecordMsg = GUIGetMsg()

Select

Case $FindRecordMsg = $GUI_EVENT_CLOSE

GUISetState(@SW_HIDE, $FindRecordForm)

ExitLoop

Case $FindRecordMsg = $FindRecordButton

;Determine total number of records to search

$var = IniReadSectionNames($inifile)

For $i = 1 To $var[0]

$RecordNo = $var[$i]

;Read each section into a variable

$newvar = IniReadSection($inifile, $i)

If @error Then

GUISetState(@SW_HIDE, $FindRecordForm)

MsgBox(0, "", "Error reading database")

ExitLoop (2)

Else

;Search the value of the key of each section

For $j = 1 To $newvar[0][0]

;Key: = $var[$i][0] & Value: = $var[$i][1])

$KeyData = $newvar[$j][0]

$ValueData = $newvar[$j][1]

;Search the value for the search term

If StringInStr($ValueData, GUICtrlRead($FindRecordInput)) Then

;If found, reset data on screen

GUISetState(@SW_HIDE, $FindRecordForm)

GUICtrlSetData($RecordNumber, $RecordNo)

GUICtrlSetData($BillingRate, IniRead($inifile, GUICtrlRead($RecordNumber), "BillingRate", ""))

GUICtrlSetData($City, IniRead($inifile, GUICtrlRead($RecordNumber), "City", ""))

GUICtrlSetData($Country, IniRead($inifile, GUICtrlRead($RecordNumber), "Country", ""))

GUICtrlSetData($Deductions, IniRead($inifile, GUICtrlRead($RecordNumber), "Deductions", ""))

GUICtrlSetData($Department, IniRead($inifile, GUICtrlRead($RecordNumber), "Department", ""))

GUICtrlSetData($EmailAddress, IniRead($inifile, GUICtrlRead($RecordNumber), "EmailAddress", ""))

GUICtrlSetData($EmergencyContactName, IniRead($inifile, GUICtrlRead($RecordNumber), "EmergencyContactName", ""))

GUICtrlSetData($EmergencyContactPhone, IniRead($inifile, GUICtrlRead($RecordNumber), "EmergencyContactPhone", ""))

GUICtrlSetData($FirstName, IniRead($inifile, GUICtrlRead($RecordNumber), "FirstName", ""))

GUICtrlSetData($HireDate, IniRead($inifile, GUICtrlRead($RecordNumber), "HireDate", ""))

GUICtrlSetData($HomeAddress, IniRead($inifile, GUICtrlRead($RecordNumber), "HomeAddress", ""))

GUICtrlSetData($HomePhone, IniRead($inifile, GUICtrlRead($RecordNumber), "HomePhone", ""))

GUICtrlSetData($LastName, IniRead($inifile, GUICtrlRead($RecordNumber), "LastName", ""))

GUICtrlSetData($MiddleName, IniRead($inifile, GUICtrlRead($RecordNumber), "MiddleName", ""))

GUICtrlSetData($Salary, IniRead($inifile, GUICtrlRead($RecordNumber), "Salary", ""))

GUICtrlSetData($SSN, IniRead($inifile, GUICtrlRead($RecordNumber), "SSN", ""))

GUICtrlSetData($State, IniRead($inifile, GUICtrlRead($RecordNumber), "State", ""))

GUICtrlSetData($Supervisor, IniRead($inifile, GUICtrlRead($RecordNumber), "Supervisor", ""))

GUICtrlSetData($Title, IniRead($inifile, GUICtrlRead($RecordNumber), "Title", ""))

GUICtrlSetData($WorkID, IniRead($inifile, GUICtrlRead($RecordNumber), "WorkID", ""))

GUICtrlSetData($WorkNo, IniRead($inifile, GUICtrlRead($RecordNumber), "WorkNo", ""))

GUICtrlSetData($WorkPhone, IniRead($inifile, GUICtrlRead($RecordNumber), "WorkPhone", ""))

GUICtrlSetData($ZipCode, IniRead($inifile, GUICtrlRead($RecordNumber), "ZipCode", ""))

ExitLoop (3)

Else

EndIf

;GUISetState(@SW_HIDE, $FindRecordForm)

;ExitLoop (3)

Next

EndIf

Next

EndSelect

WEnd

EndFunc ;==>FindRecord

Func GoToRecord()

$GoToRecordForm = GUICreate("Go To Record", 170, 31, 495, 384)

GUISetIcon("database.ico")

$GoToRecordLabel = GUICtrlCreateLabel("Record Number:", 2, 6, 82, 17)

$GoToRecordInput = GUICtrlCreateInput("", 86, 4, 47, 21)

$Go = GUICtrlCreateButton("Go", 137, 3, 28, 22, $BS_DEFPUSHBUTTON)

GUISetState(@SW_SHOW)

While 1

$RecordMsg = GUIGetMsg()

Select

Case $RecordMsg = $GUI_EVENT_CLOSE

GUISetState(@SW_HIDE, $GoToRecordForm)

ExitLoop

Case $RecordMsg = $Go

If GUICtrlRead($GoToRecordInput) < 211 Then

GUISetState(@SW_HIDE, $GoToRecordForm)

GUICtrlSetData($RecordNumber, GUICtrlRead($GoToRecordInput))

GUICtrlSetData($BillingRate, IniRead($inifile, GUICtrlRead($RecordNumber), "BillingRate", ""))

GUICtrlSetData($City, IniRead($inifile, GUICtrlRead($RecordNumber), "City", ""))

GUICtrlSetData($Country, IniRead($inifile, GUICtrlRead($RecordNumber), "Country", ""))

GUICtrlSetData($Deductions, IniRead($inifile, GUICtrlRead($RecordNumber), "Deductions", ""))

GUICtrlSetData($Department, IniRead($inifile, GUICtrlRead($RecordNumber), "Department", ""))

GUICtrlSetData($EmailAddress, IniRead($inifile, GUICtrlRead($RecordNumber), "EmailAddress", ""))

GUICtrlSetData($EmergencyContactName, IniRead($inifile, GUICtrlRead($RecordNumber), "EmergencyContactName", ""))

GUICtrlSetData($EmergencyContactPhone, IniRead($inifile, GUICtrlRead($RecordNumber), "EmergencyContactPhone", ""))

GUICtrlSetData($FirstName, IniRead($inifile, GUICtrlRead($RecordNumber), "FirstName", ""))

GUICtrlSetData($HireDate, IniRead($inifile, GUICtrlRead($RecordNumber), "HireDate", ""))

GUICtrlSetData($HomeAddress, IniRead($inifile, GUICtrlRead($RecordNumber), "HomeAddress", ""))

GUICtrlSetData($HomePhone, IniRead($inifile, GUICtrlRead($RecordNumber), "HomePhone", ""))

GUICtrlSetData($LastName, IniRead($inifile, GUICtrlRead($RecordNumber), "LastName", ""))

GUICtrlSetData($MiddleName, IniRead($inifile, GUICtrlRead($RecordNumber), "MiddleName", ""))

GUICtrlSetData($Salary, IniRead($inifile, GUICtrlRead($RecordNumber), "Salary", ""))

GUICtrlSetData($SSN, IniRead($inifile, GUICtrlRead($RecordNumber), "SSN", ""))

GUICtrlSetData($State, IniRead($inifile, GUICtrlRead($RecordNumber), "State", ""))

GUICtrlSetData($Supervisor, IniRead($inifile, GUICtrlRead($RecordNumber), "Supervisor", ""))

GUICtrlSetData($Title, IniRead($inifile, GUICtrlRead($RecordNumber), "Title", ""))

GUICtrlSetData($WorkID, IniRead($inifile, GUICtrlRead($RecordNumber), "WorkID", ""))

GUICtrlSetData($WorkNo, IniRead($inifile, GUICtrlRead($RecordNumber), "WorkNo", ""))

GUICtrlSetData($WorkPhone, IniRead($inifile, GUICtrlRead($RecordNumber), "WorkPhone", ""))

GUICtrlSetData($ZipCode, IniRead($inifile, GUICtrlRead($RecordNumber), "ZipCode", ""))

ExitLoop

Else

GUISetState(@SW_HIDE, $GoToRecordForm)

;Do Nothing

EndIf

EndSelect

WEnd

EndFunc ;==>GoToRecord

Func NewDatabase()

;Backup working copy

FileDelete("database.ini")

FileWrite("database.ini", "")

$inifile = "database.ini"

LoadData()

GUICtrlSetData($WorkID, 1)

EndFunc ;==>NewDatabase

Func OpenDatabase()

;Backup working copy

$inifile = FileOpenDialog("Open Database...", @ScriptDir, "Database Files (*.ini)")

If @error Then

;--------Do nothing if close dialog box is canceled

Else

$RecordNo = 1

LoadData()

EndIf

EndFunc ;==>OpenDatabase

Func SaveAsDatabase()

SaveData()

$inifile2 = FileSaveDialog("Choose a name", @ScriptDir, "Database Files (*.ini)")

If @error Then

;--------Do nothing if close dialog box is canceled

Else

FileCopy($inifile, $inifile2)

$inifile = $inifile2

EndIf

EndFunc ;==>SaveAsDatabase

Func ExportDatabase()

ToolTip("Exporting Database - Please Wait", @DesktopWidth / 2, (@DesktopHeight / 2), "", "", 2)

FileCopy($inifile, "worker-base.dat", 1)

$LastRecord = _ReplaceStringInFile("worker-base.dat", "WorkID", "WorkID")

For $i = 1 To $LastRecord

_ReplaceStringInFile("worker-base.dat", "[" & $i & "]", "")

Next

_ReplaceStringInFile("worker-base.dat", "BillingRate=", "")

_ReplaceStringInFile("worker-base.dat", "City=", "")

_ReplaceStringInFile("worker-base.dat", "Country=", "")

_ReplaceStringInFile("worker-base.dat", "Deductions=", "")

_ReplaceStringInFile("worker-base.dat", "Department=", "")

_ReplaceStringInFile("worker-base.dat", "EmailAddress=", "")

_ReplaceStringInFile("worker-base.dat", "EmergencyContactName=", "")

_ReplaceStringInFile("worker-base.dat", "EmergencyContactPhone=", "")

_ReplaceStringInFile("worker-base.dat", "FirstName=", "")

_ReplaceStringInFile("worker-base.dat", "HireDate=", "")

_ReplaceStringInFile("worker-base.dat", "HomeAddress=", "")

_ReplaceStringInFile("worker-base.dat", "HomePhone=", "")

_ReplaceStringInFile("worker-base.dat", "LastName=", "")

_ReplaceStringInFile("worker-base.dat", "MiddleName=", "")

_ReplaceStringInFile("worker-base.dat", "Salary=", "")

_ReplaceStringInFile("worker-base.dat", "SSN=", "")

_ReplaceStringInFile("worker-base.dat", "State=", "")

_ReplaceStringInFile("worker-base.dat", "Supervisor=", "")

_ReplaceStringInFile("worker-base.dat", "Title=", "")

_ReplaceStringInFile("worker-base.dat", "WorkID=", "")

_ReplaceStringInFile("worker-base.dat", "WorkNo=", "")

_ReplaceStringInFile("worker-base.dat", "WorkPhone=", "")

_ReplaceStringInFile("worker-base.dat", "ZipCode=", "")

ToolTip("")

EndFunc ;==>ExportDatabase

Func PrintDatabase()

FileCopy($inifile, "worker-base.txt", 1)

$LastRecord = _ReplaceStringInFile("worker-base.txt", "WorkID", "WorkID")

ToolTip("Sending to Printer - Please Wait", @DesktopWidth / 2, (@DesktopHeight / 2), "", "", 2)

For $recordx = 1 To $LastRecord

_ReplaceStringInFile("worker-base.txt", "[" & $recordx & "]", "")

Next

_ReplaceStringInFile("worker-base.txt", "BillingRate=", "")

_ReplaceStringInFile("worker-base.txt", "City=", "")

_ReplaceStringInFile("worker-base.txt", "Country=", "")

_ReplaceStringInFile("worker-base.txt", "Deductions=", "")

_ReplaceStringInFile("worker-base.txt", "Department=", "")

_ReplaceStringInFile("worker-base.txt", "EmailAddress=", "")

_ReplaceStringInFile("worker-base.txt", "EmergencyContactName=", "")

_ReplaceStringInFile("worker-base.txt", "EmergencyContactPhone=", "")

_ReplaceStringInFile("worker-base.txt", "FirstName=", "")

_ReplaceStringInFile("worker-base.txt", "HireDate=", "")

_ReplaceStringInFile("worker-base.txt", "HomeAddress=", "")

_ReplaceStringInFile("worker-base.txt", "HomePhone=", "")

_ReplaceStringInFile("worker-base.txt", "LastName=", "")

_ReplaceStringInFile("worker-base.txt", "MiddleName=", "")

_ReplaceStringInFile("worker-base.txt", "Salary=", "")

_ReplaceStringInFile("worker-base.txt", "SSN=", "")

_ReplaceStringInFile("worker-base.txt", "State=", "")

_ReplaceStringInFile("worker-base.txt", "Supervisor=", "")

_ReplaceStringInFile("worker-base.txt", "Title=", "")

_ReplaceStringInFile("worker-base.txt", "WorkID=", "")

_ReplaceStringInFile("worker-base.txt", "WorkNo=", "")

_ReplaceStringInFile("worker-base.txt", "WorkPhone=", "")

_ReplaceStringInFile("worker-base.txt", "ZipCode=", "")

ToolTip("")

$print = _FilePrint("worker-base.txt")

EndFunc ;==>PrintDatabase

Func Email()

_INetMail(GUICtrlRead($EmailAddress), "", "")

EndFunc ;==>Email

Func Home()

Run("c:\windows\dialer.exe")

$number = GUICtrlRead($HomePhone)

Sleep(1000)

Send($number)

ControlClick("Phone Dialer", "", "Button1")

EndFunc ;==>Home

Func Work()

Run("c:\windows\dialer.exe")

$number = GUICtrlRead($WorkPhone)

Sleep(1000)

Send($number)

ControlClick("Phone Dialer", "", "Button1")

EndFunc ;==>Work

Func About()

$about = GUICreate("About Worker-Base", 195, 155, -1, -1)

GUISetIcon("database.ico")

GUICtrlCreateLabel("Worker-Base", 19, 11, 135, 20)

GUICtrlCreateLabel("Copyright " & @YEAR & " Nerd Gerl", 19, 30, 175, 40)

$email = GUICtrlCreateLabel("email@address.com", 19, 70, 135, 15)

GUICtrlSetFont($email, 8.5, -1, 4); underlined

GUICtrlSetColor($email, 0x0000ff)

$www = GUICtrlCreateLabel("http://www.website.com", 19, 85, 170, 15)

GUICtrlSetFont($www, 8.5, -1, 4); underlined

GUICtrlSetColor($www, 0x0000ff)

$OK = GUICtrlCreateButton("OK", 65, 115, 75, 23, BitOR($GUI_SS_DEFAULT_BUTTON, $BS_DEFPUSHBUTTON))

GUICtrlSetState(-1, $GUI_FOCUS)

GUISetState()

While 1

$aboutmsg = GUIGetMsg()

Select

Case $aboutmsg = $OK

GUISwitch($about)

GUIDelete()

ExitLoop

Case $aboutmsg = $GUI_EVENT_CLOSE

GUISwitch($about)

GUIDelete()

ExitLoop

EndSelect

WEnd

EndFunc ;==>About

Edited by nerdgerl

My AutoIT's:[topic="53958"]Personal Encyclopedia/Dictionary[/topic][topic="46311"]MS Access (Style) Database[/topic]"Some people are born on third base and go through life thinking they hit a triple."

Share this post


Link to post
Share on other sites
James

Can you attach the file as a .au3 or put it in a codebox please? Use:

{Codebox}

{Autoit}

//CODE

{/AutoIt}

{CodeBOx}

Replace the {} with []

I get an error straight away.

C:\Documents and Settings\James\My Documents\James Programming\User Management System\database.au3(509,91) : WARNING: $WebsiteInput: possibly used before declaration.
        Run("C:\Program Files\Internet Explorer\IEXPLORE.EXE " & GUICtrlRead($WebsiteInput)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\Documents and Settings\James\My Documents\James Programming\User Management System\database.au3(516,38) : WARNING: $EMailInput: possibly used before declaration.
    _INetMail(GUICtrlRead($EMailInput)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\Documents and Settings\James\My Documents\James Programming\User Management System\database.au3(521,42) : WARNING: $CellPhoneInput: possibly used before declaration.
    $number = GUICtrlRead($CellPhoneInput)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\Documents and Settings\James\My Documents\James Programming\User Management System\database.au3(529,42) : WARNING: $HomePhoneInput: possibly used before declaration.
    $number = GUICtrlRead($HomePhoneInput)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\Documents and Settings\James\My Documents\James Programming\User Management System\database.au3(537,42) : WARNING: $WorkPhoneInput: possibly used before declaration.
    $number = GUICtrlRead($WorkPhoneInput)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\Documents and Settings\James\My Documents\James Programming\User Management System\database.au3(509,91) : ERROR: $WebsiteInput: undeclared global variable.
        Run("C:\Program Files\Internet Explorer\IEXPLORE.EXE " & GUICtrlRead($WebsiteInput)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\Documents and Settings\James\My Documents\James Programming\User Management System\database.au3 - 1 error(s), 5 warning(s)

Share this post


Link to post
Share on other sites
nerdgerl

Sorry about that. I've "boxed" it. :)

I also modified the posted code to address the "extra/misnamed" variables. Looks like I planned to add more features to this but never got around to it.

Can you attach the file as a .au3 or put it in a codebox please? Use:

{Codebox}

{Autoit}

//CODE

{/AutoIt}

{CodeBOx}

Replace the {} with []

I get an error straight away.

C:\Documents and Settings\James\My Documents\James Programming\User Management System\database.au3(509,91) : WARNING: $WebsiteInput: possibly used before declaration.
        Run("C:\Program Files\Internet Explorer\IEXPLORE.EXE " & GUICtrlRead($WebsiteInput)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\Documents and Settings\James\My Documents\James Programming\User Management System\database.au3(516,38) : WARNING: $EMailInput: possibly used before declaration.
    _INetMail(GUICtrlRead($EMailInput)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\Documents and Settings\James\My Documents\James Programming\User Management System\database.au3(521,42) : WARNING: $CellPhoneInput: possibly used before declaration.
    $number = GUICtrlRead($CellPhoneInput)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\Documents and Settings\James\My Documents\James Programming\User Management System\database.au3(529,42) : WARNING: $HomePhoneInput: possibly used before declaration.
    $number = GUICtrlRead($HomePhoneInput)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\Documents and Settings\James\My Documents\James Programming\User Management System\database.au3(537,42) : WARNING: $WorkPhoneInput: possibly used before declaration.
    $number = GUICtrlRead($WorkPhoneInput)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\Documents and Settings\James\My Documents\James Programming\User Management System\database.au3(509,91) : ERROR: $WebsiteInput: undeclared global variable.
        Run("C:\Program Files\Internet Explorer\IEXPLORE.EXE " & GUICtrlRead($WebsiteInput)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\Documents and Settings\James\My Documents\James Programming\User Management System\database.au3 - 1 error(s), 5 warning(s)

My AutoIT's:[topic="53958"]Personal Encyclopedia/Dictionary[/topic][topic="46311"]MS Access (Style) Database[/topic]"Some people are born on third base and go through life thinking they hit a triple."

Share this post


Link to post
Share on other sites
nerdgerl

Thats awesome! Well done and keep up the fantastic work.

Thanks Secure_ICT! :">


My AutoIT's:[topic="53958"]Personal Encyclopedia/Dictionary[/topic][topic="46311"]MS Access (Style) Database[/topic]"Some people are born on third base and go through life thinking they hit a triple."

Share this post


Link to post
Share on other sites
Gif

damn wrong just double posted grrrrrrrr

||

\/

Edited by c4nm7

Share this post


Link to post
Share on other sites
Gif

well that's a great work well done , keep up the good autoiting my fellow autoiter!!!

Share this post


Link to post
Share on other sites
tunaroll

Thats nice work and looks great.

I am wondering if anyone knows how I can export forms from one access database to another. I found a pretty good post on a VB forum ...

using ExportDatabaseObjects() function but being a newbie and not very experienced with VB, translating the VB to Autoit is a bit over my head.

for anyone intereste check this post .. http://www.access-programmers.co.uk/forums...ead.php?t=99179

It has VB code to export/import any/all objects from Access.

Thanks for any help or advice in advance.

Share this post


Link to post
Share on other sites
burger

nerdgerl, could you post that code as a file? Thanks!

Share this post


Link to post
Share on other sites
nerdgerl

nerdgerl, could you post that code as a file? Thanks!

I'm having trouble uploading stuff to this board...


My AutoIT's:[topic="53958"]Personal Encyclopedia/Dictionary[/topic][topic="46311"]MS Access (Style) Database[/topic]"Some people are born on third base and go through life thinking they hit a triple."

Share this post


Link to post
Share on other sites
burger

Thanks for trying. When I copy your code and try to paste it into the editior, it put's it all on one line.

Share this post


Link to post
Share on other sites
nerdgerl

Thanks for trying. When I copy your code and try to paste it into the editior, it put's it all on one line.

I could try and email it to you...


My AutoIT's:[topic="53958"]Personal Encyclopedia/Dictionary[/topic][topic="46311"]MS Access (Style) Database[/topic]"Some people are born on third base and go through life thinking they hit a triple."

Share this post


Link to post
Share on other sites
nerdgerl

You should be able to upload now. You have to get 10-15 posts before you can upload.

Whenever I try, "Uploading File..." shows up but just hangs. :-(


My AutoIT's:[topic="53958"]Personal Encyclopedia/Dictionary[/topic][topic="46311"]MS Access (Style) Database[/topic]"Some people are born on third base and go through life thinking they hit a triple."

Share this post


Link to post
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
Sign in to follow this  

×