Problem Retrieving variable value from a userform back to the sub

indyman

New Member
Joined
Apr 14, 2021
Messages
47
Office Version
  1. 2019
Platform
  1. Windows
I am finding tons of similar answers to this, but they do not seem to fix my issue. I have a Private Sub DeleteRecord that calls a Public Function recDelete(RowNum As Integer, Payer As String) As Boolean, which is a regular module. In the function, I open a form ufDecision, which I intend to use for multiple record type deletion "Are you sure"... prompts. In the ufDecision, I have this code to capture a response to proceed with deletion:
```
Private Sub imgProceed_Click()
Answer = True
Me.Hide
End Sub
```
I thin intend to assign ```recDelete = Answer``` to pass back to the DeleteRecord sub. Answer is a publicly declared Boolean. After the code is stepped through and confirmed to go through the True assignment, Answer always show false (empty actually). I guess I have tunnel vision. So what am I missing?
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
Oops, looks like I did not use the proper code tags. Nor does it look like I can edit.
 
Upvote 0
I resolved this. I have a lot of subs across several userforms. Ultimately, even though I had the variable as a public boolean, I had older code setting it to a string.

@Moderator, feel free to delete this thread, as I suspect it will add no value to anyone landing on it.
 
Upvote 0

Forum statistics

Threads
1,214,641
Messages
6,120,688
Members
448,978
Latest member
rrauni

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