Micro Focus QTP (UFT) Forums
Clicking command button in accesss form - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: VB Scripting/Descriptive Programming (https://www.learnqtp.com/forums/Forum-VB-Scripting-Descriptive-Programming)
+--- Thread: Clicking command button in accesss form (/Thread-Clicking-command-button-in-accesss-form)



Clicking command button in accesss form - mark_cielos24@yahoo.com - 05-05-2013

Hi,

I am trying to automate an application that uses MS Access Forms. I still need what methods are available, currently I am trying to do the login part. I am able to give the username, password & select the DSN then I need to click the [OK] button but that is what I am not able to do. Its a command button from an Access Form, in its Event Property of "On Click" its has a value of [Event Procedure] which if you look at it will bring you to MS Visual Basic and see that it call a procedure to perform. May someone please help me show the syntax or method on how my script be able to control/click this using qtp/vbscript. I mean in terms of manually doing it I just need to click the [OK] button where how will I do this in terms of automation/qtp/vbscript, see my code below:

Code:
sPathToSample = "C:\Program Files\Application\"
sSampleFilename = "Sample.mdb"
sFilePath = sPathToSample & sSampleFilename

Set oAccess = CreateObject("Access.Application")
oAccess.OpenCurrentDatabase(sFilePath)

sFormName = "frmODBCLogon"
Set oForms = oAccess.Forms(sFormName)

sUID = "txtODBCuid"
sPassword = "txtODBCpwd"
sDSN = "cboDSNList"
sOK = "cmdOK"

Set oUID = oForms(sUID)
Set oDSN = oForms(sDSN)
Set oPasswd = oForms(sPassword)
Set oOK = oForms(sOK)

oUID.Value = "username"
oPasswd.Value = "password"
oDSN.Value = "DSN"
[b]oOK.OnClick = "[Event Procedure]"
'This is where I need help[/b]

Thanks,


RE: Clicking command button in accesss form - agarwl.anurag - 05-07-2013

Use the sendkey method to bring focus on the Ok button and then click on it..