Pass userform reference to public function

I am setting up some vba userforms for grabbing info in Microstation and storing it in an access database.  Since the forms will be doing the same thing for different data, I wanted to write public functions for the form actions (clear form, check for duplicate records, etc)  So I tried to pass the "Me" keyword to the function with:

Public function clearform( frm as form)

for each ctl in frm.controls

blah

blah

end function

in the forms button I would have

clearform(me)  'to call the funtion.

I am getting type mismatch error.

I don't know if I am missing a reference,  I've tried different variations like "frm as userform"

If anyone had an example I would greatly appreciate it

Thanks in advance

 

Parents
  • Hi,

    Try "frm as Object"

    In my routine (Mstn v8i) I happen to say "Set frm =MyFormName", so I have not tested the "Me" function.

    --Robert

  • I tried "frm as Object",

    I'm not sure if I should be referring to "forms"  "userForms"  "MsForms" or what.  The last route I tried was passing the form name and using  "frm.show"

    Didn't work, but at this point I'm not sure if it was the syntax or the process.  

    I will have to regroup and post some code if I still can't get it to work.  It has been a couple years since I played with vba forms, I have to figure out what I did know.

    I appreciate any information, and will have time to play with this this weekend, but no internet.  I will check for responses, or post new findings next week.

    Thanks again

  • UserForm is not a UserForm

    There's something wrong with VBA here. I can reproduce your perplexity.

    According to VBA Help, a UserForm has a Show method. In other words, the following should be legal …

    Dim oForm As UserForm
    Set oForm = New MyUserForm
    oForm.Show

    However, when I examine that code, I can see that UserForm.Show does not exist, nor does it show up in the object browser (key F2).

    I don't know whether this is something to do with VBA versioning, but whatever it is we have no control over it. File a Trouble Report (TR) with Bentley Systems.

    Regards, Jon Summers
    LA Solutions

     
    Regards, Jon Summers
    LA Solutions

Reply
  • UserForm is not a UserForm

    There's something wrong with VBA here. I can reproduce your perplexity.

    According to VBA Help, a UserForm has a Show method. In other words, the following should be legal …

    Dim oForm As UserForm
    Set oForm = New MyUserForm
    oForm.Show

    However, when I examine that code, I can see that UserForm.Show does not exist, nor does it show up in the object browser (key F2).

    I don't know whether this is something to do with VBA versioning, but whatever it is we have no control over it. File a Trouble Report (TR) with Bentley Systems.

    Regards, Jon Summers
    LA Solutions

     
    Regards, Jon Summers
    LA Solutions

Children