3 Replies - 2313 Views - Last Post: 16 November 2011 - 02:00 PM Rate Topic: -----

#1 AN1554  Icon User is offline

  • D.I.C Head

Reputation: 7
  • View blog
  • Posts: 130
  • Joined: 03-April 11

"Compile error. Invalid qualifier." for procedure in module

Posted 13 November 2011 - 08:41 AM

This code is in a form:

Private Sub cmdUndo_Click()
Call ClearTextboxes(Me.Name)
End Sub


The code for procedure ClearTextboxes is in a module:

Public Sub ClearTextboxes(ByVal FormName As String)
For Each ctl In FormName.Controls
    If TypeOf ctl Is TextBox Then
        ctl.Text = ""
    End If
Next
End Sub


When program runs, message box appears with "Compile error. Invalid qualifier" and FormName is highlighted. It means FormName is an invalid qualifier, but trying "qualifiers" other than FormName gives same result. What is wrong? Thanks.

This post has been edited by AN1554: 13 November 2011 - 08:42 AM


Is This A Good Question/Topic? 0
  • +

Replies To: "Compile error. Invalid qualifier." for procedure in module

#2 smohd  Icon User is offline

  • Critical Section
  • member icon


Reputation: 1819
  • View blog
  • Posts: 4,627
  • Joined: 14-March 10

Re: "Compile error. Invalid qualifier." for procedure in module

Posted 13 November 2011 - 09:14 AM

FormName is a string, it has no Controls property. If you need to use the controls property, than you have to pass the form itself and not the name, because name is treated as string after reaching there.
Was This Post Helpful? 1
  • +
  • -

#3 AN1554  Icon User is offline

  • D.I.C Head

Reputation: 7
  • View blog
  • Posts: 130
  • Joined: 03-April 11

Re: "Compile error. Invalid qualifier." for procedure in module

Posted 13 November 2011 - 10:36 AM

So, FormName simply has to be declared as Form. Thanks a lot for the explanation.

This post has been edited by AN1554: 13 November 2011 - 10:40 AM

Was This Post Helpful? 0
  • +
  • -

#4 BobRodes  Icon User is offline

  • Your Friendly Local Curmudgeon
  • member icon

Reputation: 574
  • View blog
  • Posts: 2,989
  • Joined: 19-May 09

Re: "Compile error. Invalid qualifier." for procedure in module

Posted 16 November 2011 - 02:00 PM

Well, that's true, but you also have to make another change. You can't pass a string to a parameter of type Form. Do you know what else you have to do?
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1