I have an inputbox that asks the user for the number of relatives they live with. But in the inputbox when I clicked on the cancel or accept button I got a type mismatch error. However, what I was able to solve was that when I click cancel or accept, I get an empty form and I simply want it to do nothing that does not execute any action.
numFamiliares = Val(InputBox("How many family members do you live with?"))
If numFamiliares = 0 Then Exit Sub
familiarActual = 1
....Here goes the rest of the code....
I simply want it not to show me the empty form as it is doing, only if the user clicks accept or cancel, simply do nothing, it must execute the rest of the code only if the number of family members is entered.Link File. Here I leave the link of the file if anyone wants to see it, it was built in execution mode.
numFamiliares = Val(InputBox("How many family members do you live with?"))assigns either the number you enter or 0 if you enter text.0family members and as your code stands, it will exit the subModule1) and declare the variable globally withPublic numFamiliares As Longoutside the sub. AfterExit Subadd something likeDim uf As Object: Set uf = New Frm.Familiar: uf.Show. But there might be much more to it: read about how it's properly done here.