Multipage tool accesing same form to put data in textboxes

Bandito1

Board Regular
Joined
Oct 18, 2018
Messages
233
Office Version
  1. 2016
Platform
  1. Windows
Hello all,

I use this multipage tool to be able to add multiple corrections to my excel database.
In my form i have a textbox where i enter names through a form with a listbox.
This form is accessed through the button cmdContacts.

This button is on page 1 of the multipage and on page 2.

Code:
Private Sub cmdContacts_Click()
frmPersonSearch.Show
End Sub

The listbox on frmPersonsearch got this code;

Code:
Private Sub lstSearchResults_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
Productionreturns.txtCorrectBy2.value = Application.WorksheetFunction.VLookup(Me.lstSearchResults.value, Sheets("Shifts").Range("A1:D100"), 2, False)
Unload Me
End Sub

But on page 1 of my multipage the textbox is names txtcorrectby and on page 2 it's txtcorrectby2.

How do i tell that when i acces frmPersonSearch from page 1 that it should fill txtcorrectby and when i acces frmPersonSearch from page 2 it should fill txtcorrectby2 and not txtcorrectby.

Hope i was clear..

Thanks in advance
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
Well to tell a multipage to make decisions based on what Multipage you have activated when the script is run you do something like this.

This is a simple example.
VBA Code:
Private Sub CommandButton2_Click()
'Modified  12/5/2019  7:36:51 AM  EST
MsgBox Me.MultiPage1.Pages(MultiPage1.Value).Caption
End Sub
 
Upvote 0
Or if you need more help using a if statement it would look like this.
Code:
Private Sub CommandButton2_Click()
'Modified  12/5/2019  7:46:51 AM  EST
Dim ans As String
ans = Me.MultiPage1.Pages(MultiPage1.Value).Caption
If ans = "Mom" Then MsgBox "Is Supper ready " & ans
If ans = "Dad" Then MsgBox "Does the car have gas " & ans

End Sub
 
Upvote 0
Hello,

Thanks for your reaction.
I got problems understanding it.

I got the button cmdContacts that opens the form frmPersonSearch.
Where should i put the code?

I tried in cmdContacts but i don't see how it determines where to put the data;

Code:
Private Sub cmdContacts_Click()
Dim ans As String
ans = Me.MultiPage1.Pages(MultiPage1.value).Caption
If ans = "Page 1" Then
frmPersonSearch.Show
End Sub

in fromPersonSearch;

Code:
Private Sub lstSearchResults_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
Productionreturns.txtCorrectBy2.value = Application.WorksheetFunction.VLookup(Me.lstSearchResults.value, Sheets("Shifts").Range("A1:D100"), 2, False)
Unload Me
End Sub

I don't know how to combine it..
 
Upvote 0
For me to help I need to know what your attempting to do.
All you said was:
I use this multipage tool to be able to add multiple corrections to my excel database.
Corrections? What corrections
Database? Where on your Database.
Or Workbook as we call it.
And it looks like you want your multipage to open a Userform
Like here:
If ans = "Page 1" Then
frmPersonSearch.Show
 
Upvote 0
Hello,

I will try to explain.

With the following form users can add data to the worksheet;

001.PNG


My question is about the textbox "To Correct by".
The icon behind this textbox opens frmPersonSearch.

frmPersonSearch;
002.PNG


This button is also on page 2, 3, 4 and 5 of the multipage.

Names apear in PersonSearch and when you double click on them it appears in the textbox behind To Correct by.

Now i don't know how to "tell" that when PersonSearch opens on page 2 it should fill txtCorrectBy2 and when it's opened from page 3 it should fill txtCorrectBy3.
 
Upvote 0

Forum statistics

Threads
1,214,833
Messages
6,121,862
Members
449,052
Latest member
Fuddy_Duddy

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