Forum Discussion

joffre's avatar
joffre
Regular Contributor
12 years ago

Generic object for Event .ClickButton(cbChecked)

Hi all.



I'm creating a generic function that will receive 3 parameters:

> nomeColuna - Column name (will receive the column name from DataBase)

> nomeComponente - Form's label (will receive the name of the object that will be selected)

> itemClicado - Item Clicked - (will receive the form object that is a checkbox)



Here is the function:

function verificarClickCheckBox(nomeColuna, nomeComponente, itemClicado)

{

  loadTipoAtividadeNormalVariaveis();

  if (registros.Fields(nomeColuna).Value == "S") {

    Log.Message("Seleciona o item " + itemClicado)

    nomeComponente.ClickButton(cbChecked);

  }

}


The 'nomeComponente' variable is receiving the CheckBox, but it isn't working. The problem is when it arrives at the last if line, it returns the error attached, that translating into english means The object doesn't support the property or method.



What can I do?
  • Here





    verificarClickCheckBox("bTRABALHADOR_URBANO_PJ", "chkTrabalhadorUrbanoPJ", "Trabalhador Urbano - PJ - CLT");



    Don't pass in the label. Don't pass in the string. Pass in the actual object. You have an object var






    chkTrabalhadorUrbanoPJ = Sys.Process("FPw5_CadCalc").VBObject("Form1").Window("MDIClient").VBObject("cdSituacoes").VBObject("fraSituacao_5").VBObject("Vinculos_11");






    Pass it into the procedure and use it.







     


  • sastowe's avatar
    sastowe
    Super Contributor
    Here





    verificarClickCheckBox("bTRABALHADOR_URBANO_PJ", "chkTrabalhadorUrbanoPJ", "Trabalhador Urbano - PJ - CLT");



    Don't pass in the label. Don't pass in the string. Pass in the actual object. You have an object var






    chkTrabalhadorUrbanoPJ = Sys.Process("FPw5_CadCalc").VBObject("Form1").Window("MDIClient").VBObject("cdSituacoes").VBObject("fraSituacao_5").VBObject("Vinculos_11");






    Pass it into the procedure and use it.







     


  • sastowe's avatar
    sastowe
    Super Contributor
    It is erroring on this line



     if (registros.Fields(nomeColuna).Value == "S") {



    Where is the registros object declared? If that object does not exist, then it won't have a fields collection.



    I may be full of balogna, but that is what I see.
  • joffre's avatar
    joffre
    Regular Contributor
    It is erroring on this line

     if (registros.Fields(nomeColuna).Value == "S") {



    Where is the registros object declared? If that object does not exist, then it won't have a fields collection.

    I may be full of balogna, but that is what I see.




    Hello, thanks for your reply.



    The registros variable is being declared on other function.

    As I said, the problem is on line:

    nomeComponente.ClickButton(cbChecked);
    and the returned error is attached.

    The 'nomeComponente' will be replaced by a CheckBox component name, but it isn't working as expected (it isn't working at all).
  • sastowe's avatar
    sastowe
    Super Contributor
    OK. The original post indicates that





    nomeComponente - Form's label (will receive the name of the object that will be selected)





    So ... nomeComponente is a string? In that case you need pass in the actual object instead. A string has no properties or methods.
  • joffre's avatar
    joffre
    Regular Contributor


    Exactly! You understood that idea... we are almost there.



    On my test, I'll call this function like this:



    verificarClickCheckBox("bTRABALHADOR_URBANO_PJ", "chkTrabalhadorUrbanoPJ", "Trabalhador Urbano - PJ - CLT");



    Where chkTrabalhadorUrbanoPJ is declared as:



    chkTrabalhadorUrbanoPJ = Sys.Process("FPw5_CadCalc").VBObject("Form1").Window("MDIClient").VBObject("cdSituacoes").VBObject("fraSituacao_5").VBObject("Vinculos_11");



    What I want to know is if there's a generic CheckBox object that will be replaced for the real CheckBox object. So, I can use just this line several times, instead of create a new if for each CheckBox of my application.