Object variable or with block variable not set in 2 places but nowhere else with same code

bioplz

New Member
Joined
Dec 1, 2021
Messages
15
Office Version
  1. 2019
Platform
  1. Windows
In only 2 of 27 buttons this error occurs. In the first instance, it works, but any other selection after causes error.
1644341958812.png
1644342064511.png

When selecting Test 28 (or 29) with train 7 (The first Train) They work just fine.
Any train after causes the error on 28 and 29.
Train number is a value carried through multiple forms in a text box.
1644342300021.png

The issue highlights "frmTest29.txtTrain = Me.txtTrain"
The value of "Me.txtTrain" is correct (7, 8, 9, etc.)
The value of "frmTest28.txtTrain" contains the error.

If anyone can shine some light on this issue it would be greatly appreciated.
 
For me, it raises that error here:
VBA Code:
    Else
        UserForm21.Label3.BackColor = vbWhite
    End If
You don't have a userform21.

a_userForms.jpg

Your file is far too difficult to troubleshoot. When it errors and I have to stop code, I have to attempt to open the file again two times, closing any blank workbooks that open, just to get back to the login screen and start over. After spending about 2 hours trying to figure out what's going on I think I must bow out if I haven't already found the problem.
 
Upvote 0
Solution

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
For me, it raises that error here:
VBA Code:
    Else
        UserForm21.Label3.BackColor = vbWhite
    End If
You don't have a userform21.

View attachment 57522
Your file is far too difficult to troubleshoot. When it errors and I have to stop code, I have to attempt to open the file again two times, closing any blank workbooks that open, just to get back to the login screen and start over. After spending about 2 hours trying to figure out what's going on I think I must bow out if I haven't already found the problem.
After almost giving up, I went back to fix this issue and that fixed the error. Changing UserForm21 to frmTest29 solved the issue.
Thank you for you help and patience.
 
Upvote 0

Forum statistics

Threads
1,214,935
Messages
6,122,337
Members
449,077
Latest member
Jocksteriom

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