Clling a module process

ipbr21054

Well-known Member
Joined
Nov 16, 2010
Messages
5,736
Office Version
  1. 2007
Platform
  1. Windows
I have a module called RESET_VALUES

The code on it is supplied below but when calling ResetFields im told incorrect etc.
Did i miss something

Rich (BB code):
Sub ResetFields()

TextBox3.SetFocus
TextBox1.Value = ""
TextBox2.Value = ""
TextBox3.Value = ""
TextBox4.Value = ""
TextBox5.Value = ""
TextBox6.Value = ""
TextBox7.Value = ""

TextBox2.Visible = False
TextBox6.Visible = False
TextBox7.Visible = False
TextBox10.Visible = False
TextBox11.Visible = False

OptionButton1.Value = False
OptionButton2.Value = False
OptionButton3.Value = False
OptionButton4.Value = False
OptionButton5.Value = False
OptionButton6.Value = False
OptionButton7.Value = False
OptionButton8.Value = False
OptionButton9.Value = False

OptionButton8.Visible = True
OptionButton9.Visible = True

Label8.Visible = True
Label9.Visible = True

TextBox9.SetFocus
GenerateCode.Visible = True

End Sub
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
Incorrect what? How exactly did you call it?
 
Upvote 0
I have changed the sub name above from Sub ResetFields() to Sub RESET()

In my worksheet io put Call RESET & it didnt error out this time BUT debugs to this sub mentioned above as Not Defined

So after Sub RESET() i need to add something before the rest of the text but not sure how to
 
Upvote 0
im told incorrect etc.
Please provide the actual error number and the message. If it's a compile error, what is the message and what line is highlighted? You could also condense your code like this:
VBA Code:
Sub ResetFields()
Dim i As Integer

TextBox3.SetFocus
For i = 1 to 7
    Me.Controls("TextBox" & i) = ""
Next
TextBox2.Visible = False
TextBox6.Visible = False
TextBox7.Visible = False
TextBox10.Visible = False
TextBox11.Visible = False
For i = 1 to 9
    Me.Controls("OptionButton1" & i) = False
Next
OptionButton8.Visible = True
OptionButton9.Visible = True
Label8.Visible = True
Label9.Visible = True
TextBox9.SetFocus
GenerateCode.Visible = True

End Sub
Giving the focus to textbox3 then to 9 like that doesn't make sense. Neither does worrying about the visibility of the controls near the end of the code unless something happened elsewhere to alter that.
 
Upvote 0
If the reset code is not in a userform code module (or a worksheet with a lot of activex controls) then it won't work because you haven't specified where any of those controls are.
 
Upvote 0
OK
I Call it like so Call RESET

I then see a compile erro,variable not defined.

I am on a userform & once finished i will to clear Textboxes etc & that is when i get the error message.
See screenshot.

I suppose maybe the code doesnt know where the userform is etc ?
 

Attachments

  • EaseUS_2023_12_18_16_18_28.jpg
    EaseUS_2023_12_18_16_18_28.jpg
    82.4 KB · Views: 10
Upvote 0
Your RESET code should be in the userform code module.
 
Upvote 0
Right click the userform object and choose view code.
 
Upvote 0
Thats where i had it at the start but was to long so thought i would put in module

So now on the sheet i have the following code below.
I call it like this Call ResetFields but i see Compile error invalid use of property,see screenshow


Rich (BB code):
Private Sub ResetFields_Click()
Dim i As Integer

TextBox9.SetFocus
For i = 1 To 7
    Me.Controls("TextBox" & i) = ""
Next
TextBox2.Visible = False
TextBox6.Visible = False
TextBox7.Visible = False
TextBox10.Visible = False
TextBox11.Visible = False
For i = 1 To 9
    Me.Controls("OptionButton1" & i) = False
Next
OptionButton8.Visible = True
OptionButton9.Visible = True
Label8.Visible = True
Label9.Visible = True
TextBox9.SetFocus
GenerateCode.Visible = True

End Sub
 

Attachments

  • EaseUS_2023_12_18_16_33_36.jpg
    EaseUS_2023_12_18_16_33_36.jpg
    47.2 KB · Views: 6
Upvote 0

Forum statistics

Threads
1,223,893
Messages
6,175,241
Members
452,622
Latest member
Laura_PinksBTHFT

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top