D
Damian
I'm trying to use the .Net interop assembles as a test-bed for an Access 2003
application. This appears to be the best tool since I can traverse the
objects on a form, etc.
BUT - how the heck do I click a command button?? Here's my code so far:
private void ClickOneSourceButton(string strFormName, string strButtonName)
{
//find the form
Microsoft.Office.Interop.Access.Form myAccessForm = null;
foreach (Microsoft.Office.Interop.Access.Form tempForm in oAccess.Forms)
{
if (tempForm.Name == strFormName)
{
myAccessForm = tempForm;
break;
}
}
if (myAccessForm != null)
{
//find the control
Microsoft.Office.Interop.Access.CommandButton myButton = null;
foreach (Microsoft.Office.Interop.Access.Control tempControl in
myAccessForm.Controls)
{
try
{
Microsoft.Office.Interop.Access.CommandButton tempButton =
(Microsoft.Office.Interop.Access.CommandButton)tempControl;
if (tempButton.Name == strButtonName)
{
//we've got our freakin button
myButton = tempButton;
}
}
catch {}
if (myButton != null) break;
}
//click the freakin button
if (myButton != null)
{
..
..
..
My best attempt at clicking the button is:
oAccess.Run("OneSource" + "." + myAccessForm.Name + "." + myButton.OnClick
EVEN if I test this by putting in a literal string with the name of the
button click event it doesn't work...
Any ideas?
Failing that am I using the wrong tool as testing tool??
Thanks!!
Damian
application. This appears to be the best tool since I can traverse the
objects on a form, etc.
BUT - how the heck do I click a command button?? Here's my code so far:
private void ClickOneSourceButton(string strFormName, string strButtonName)
{
//find the form
Microsoft.Office.Interop.Access.Form myAccessForm = null;
foreach (Microsoft.Office.Interop.Access.Form tempForm in oAccess.Forms)
{
if (tempForm.Name == strFormName)
{
myAccessForm = tempForm;
break;
}
}
if (myAccessForm != null)
{
//find the control
Microsoft.Office.Interop.Access.CommandButton myButton = null;
foreach (Microsoft.Office.Interop.Access.Control tempControl in
myAccessForm.Controls)
{
try
{
Microsoft.Office.Interop.Access.CommandButton tempButton =
(Microsoft.Office.Interop.Access.CommandButton)tempControl;
if (tempButton.Name == strButtonName)
{
//we've got our freakin button
myButton = tempButton;
}
}
catch {}
if (myButton != null) break;
}
//click the freakin button
if (myButton != null)
{
..
..
..
My best attempt at clicking the button is:
oAccess.Run("OneSource" + "." + myAccessForm.Name + "." + myButton.OnClick
EVEN if I test this by putting in a literal string with the name of the
button click event it doesn't work...
Any ideas?
Failing that am I using the wrong tool as testing tool??
Thanks!!
Damian