Call Sub Problem

Kavy

Well-known Member
Joined
Jun 25, 2007
Messages
607
Hello, I am using a user Form in excel VB

I have a bunch of text boxes on another form. What set of text boxes i use depend on what illertation I am on, "counter". I am calling the sub which uses the "Select Case" code to figure out which textbox to use.

When I run it, it reaches the call, goes into the sub, and when it exits the sub it screws up. It says "Type miss match"

Intresting note, if you click play again, it works right away untill it runs another illertation through and gets back to that spot.

In the call function in the code below, all variables have Nothing in them when I put my mouse over them in debug. When I say nothing it actually says like textboxy = Nothing

counter has 1 to start.

Here is my code if anyone can help, thanks for any help at all!




Code:
Call subcase(textboxy, textboxM, textboxMa, textboxw, textboxd, checkboxx, counter)

and here is the sub! thanks again!

Code:
 Sub subcase(textboxy, textboxM, textboxMa, textboxw, textboxd, checkboxx, counter)

Select Case counter
                
                Case 1
                Set textboxy = frmNewItemMore.txtYear1
                Set textboxM = frmNewItemMore.txtMonth1
                Set textboxw = frmNewItemMore.txtweek1
                Set textboxd = frmNewItemMore.txtDay1
                Set textboxMa = frmNewItemMore.txtPM1
                Set checkboxx = frmNewItemMore.chk1
                Case 2
                Set textboxy = frmNewItemMore.txtYear2
                Set textboxM = frmNewItemMore.txtMonth2
                Set textboxw = frmNewItemMore.txtweek2
                Set textboxd = frmNewItemMore.txtDay2
                Set textboxMa = frmNewItemMore.txtPM2
                Set checkboxx = frmNewItemMore.chk2
                Case 3
                Set textboxy = frmNewItemMore.txtYear3
                Set textboxM = frmNewItemMore.txtMonth3
                Set textboxw = frmNewItemMore.txtweek3
                Set textboxd = frmNewItemMore.txtDay3
                Set textboxMa = frmNewItemMore.txtPM3
                Set checkboxx = frmNewItemMore.chk3
                Case 4
                Set textboxy = frmNewItemMore.txtYear4
                Set textboxM = frmNewItemMore.txtMonth4
                Set textboxw = frmNewItemMore.txtweek4
                Set textboxd = frmNewItemMore.txtDay4
                Set textboxMa = frmNewItemMore.txtPM4
                Set checkboxx = frmNewItemMore.chk4
                Case 5
                Set textboxy = frmNewItemMore.txtYear5
                Set textboxM = frmNewItemMore.txtMonth5
                Set textboxw = frmNewItemMore.txtweek5
                Set textboxd = frmNewItemMore.txtDay5
                Set textboxMa = frmNewItemMore.txtPM5
                Set checkboxx = frmNewItemMore.chk5
                Case 6
                Set textboxy = frmNewItemMore.txtYear6
                Set textboxM = frmNewItemMore.txtMonth6
                Set textboxw = frmNewItemMore.txtweek6
                Set textboxd = frmNewItemMore.txtDay6
                Set textboxMa = frmNewItemMore.txtPM6
                Set checkboxx = frmNewItemMore.chk6
                Case 7
                Set textboxy = frmNewItemMore.txtYear7
                Set textboxM = frmNewItemMore.txtMonth7
                Set textboxw = frmNewItemMore.txtweek7
                Set textboxd = frmNewItemMore.txtDay7
                Set textboxMa = frmNewItemMore.txtPM7
                Set checkboxx = frmNewItemMore.chk7
    End Select
End Sub
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
So its not my call function, i moved some stuff out of the call function to see if it would work

If i have textbox delcared as a textbox

how come i can't go

txtbox = frmkavy.txtbox
 
Upvote 0
There are at least 3 types of textboxes.

1 Userform ones.

2 Ones from the Control Toolbox toolbar.

3 From the Forms toolbar.
 
Upvote 0
ahhh well thanks for your help on this, sorry if this was a bit of a wild gooes chase
 
Upvote 0

Forum statistics

Threads
1,215,425
Messages
6,124,826
Members
449,190
Latest member
rscraig11

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