JohnW Posted February 23, 2009 Share Posted February 23, 2009 (edited) I have a program that reads in a phone number and comes back with information it looked up in a database and displays the information in a list and label. I have created a button that when clicked I want it to send information to the clipboard and then exit. For some reason I cannot get the button to do anything when clicked. I am sure I am missing something simple but here is the code and any help would be greatly appreciated. expandcollapse popup#include<array.au3> #include<Access.au3> #include<GuiConstantsEx.au3> #include <GUIListBox.au3> Opt('MustDeclareVars', 1) Opt("GUIOnEventMode", 1) global $sqlCon,$adoRs,$output,$phonenumber,$address,$city,$state,$zip,$qryPhone,$phoneDash,$custID,$addressid global $custName, $inphone, $outputcust, $DBLoc,$count,$PickWnd,$custlist,$custlabel,$clipBtn If $cmdline[0] <> 0 Then $inphone = $cmdline[1] ;~ $outputcust = $cmdline[2] ;~ msgbox(0,"error",$inphone) Else Msgbox(0,"Error","No parameters given") EndIf $pickWnd= GuiCreate("PhonePop",500,250) GUISetOnEvent($GUI_EVENT_CLOSE, "_Events") GUISetOnEvent($GUI_EVENT_MINIMIZE, "_Events") GUISetOnEvent($GUI_EVENT_RESTORE, "_Events") $custlist = GUICtrlCreateList("",10,10,240,125) $custlabel = GuiCtrlCreateLabel("",260,10,200,125) $clipBtn = GuiCtrlCreateButton("Ok",225,175,50) GUISetOnEvent($clipBtn,"ClipButton") ConnectDB() GUISwitch($pickWnd) GUISetState(@SW_Show,$pickWnd) while 1 Sleep(60) WEnd Func ConnectDB() $DBLoc = IniRead("PhonePop.ini","DatabaseLoc","DB","") $sqlCon = ObjCreate("ADODB.Connection") $sqlCon.Open("DRIVER={Microsoft Access Driver (*.mdb)};DBQ=" & $DBLoc) ;~ $qryPhone = getPhoneNo() $qryPhone = $inphone $phoneDash = StringMid($qryPhone,1,3) & "-" & stringMid($qryPhone,4,3) & "-" & StringMid($qryPhone,7,4) ;~ msgbox(0,"Test",$phoneDash) ;~ msgbox(0,"Test",$outputcust) $count = 0 $adoRs = $sqlCon.Execute("Select DISTINCT * From Gehl WHERE Phone ='" & $phoneDash & "'") with $adoRs While Not .EOF $count=$count +1 .moveNext Wend If $count = 0 Then Exit EndIf EndWith ;~ msgbox(0,"",$count) with $adoRs .moveFirst While Not .EOF $custID = $adoRs.Fields("CUSTOMER Id").value $custName = $adoRs.Fields("Customer Name").value ;$addressid = $adoRs.Fields("ADDRESS Line1").value ;$address = $adoRs.Fields("ADDRESS Line2").value ;$zip = $adoRs.Fields("ZIP CODE").value $city = $adoRs.Fields("CITY").value $state = $adoRs.Fields("STATE").value $phonenumber = $adoRs.Fields("Phone").value GUICtrlSetData($custlist,$custID) $output = $custName & @CRLF & $city & ", " & $state & @CRLF & @CRLF & $phonenumber Guictrlsetdata($custlabel,$output) ;~ msgbox(0,"Test",$output ) ;~ ClipPut($custID) .moveNext WEnd EndWith $sqlCon.Close ;~ Exit EndFunc Func ClipButton() ClipPut("11111111") Exit EndFunc Func _Events() Switch @GUI_CtrlId Case $GUI_EVENT_CLOSE Exit Case $GUI_EVENT_MINIMIZE Case $GUI_EVENT_RESTORE Case Else EndSwitch Endfunc Edited February 23, 2009 by JohnW Link to comment Share on other sites More sharing options...
exodius Posted February 23, 2009 Share Posted February 23, 2009 Use GuiSetOnEvent for the special GUI messages (like $GUI_EVENT_CLOSE). Use GuiCtrlSetOnEvent for your GUI controls. Link to comment Share on other sites More sharing options...
JohnW Posted February 23, 2009 Author Share Posted February 23, 2009 Thanks, I knew it had to be something simple. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now