Hard to make suggestions without knowing the logic of what you're trying
to
do.
Okay.
I have an access database that has three fields: Japanese term, English
term, and Client. I call it from Word using macros and forms.
One thing I do is look to see if a particular client has an English entry
for a particular Japanese term. Failing that, I can see if any client has an
entry for that term, or do a wildcard search and see if there are any
entries for any client containing the term. I can also go backwards and
check an English term.
UserForm3 does the search for the exact term for any client, and lists
English, Japanese, and client for all hits in a listbox.
UserForm4 does the wildcard search for all occurences of the term, and lists
English, Japanese, and client for all hits in a listbox.
UserForm11 does the search for an English term and lists the English,
Japanese, and client in a listbox.
One of the command buttons on these three user forms is "modify entry." This
pops up userform 10, which has 3 text boxes: one for the J, one for the E,
and one for the client. Changing the text in these boxes and hitting
"change" changes the entry in the Access database to match.
At first, I only modified entries from userform4. At that point, this code
worked fine:
Private Sub UserForm_Activate()
JString = GlossaryForm4.ListBox1.Column(0)
EString = GlossaryForm4.ListBox1.Column(1)
CString = GlossaryForm4.ListBox1.Column(2)
With tbxEntry
GlossaryForm10.JapaneseBox.Text = JString
GlossaryForm10.JapaneseBox.SetFocus
GlossaryForm10.JapaneseBox.SelStart = 0
GlossaryForm10.JapaneseBox.SelLength =
Len(GlossaryForm10.JapaneseBox.Text)
GlossaryForm10.EnglishBox.Text = EString
GlossaryForm10.EnglishBox.SelStart = 0
GlossaryForm10.EnglishBox.SelLength =
Len(GlossaryForm10.EnglishBox.Text)
GlossaryForm10.ClientBox.Text = CString
GlossaryForm10.ClientBox.SelStart = 0
GlossaryForm10.ClientBox.SelLength =
Len(GlossaryForm10.ClientBox.Text)
End With
End Sub
Now, though, I also want to call userform10 and modify entries from
userform3 and userform11, and
JString = GlossaryForm4.ListBox1.Column(0)
EString = GlossaryForm4.ListBox1.Column(1)
CString = GlossaryForm4.ListBox1.Column(2)
doesn't allow me to do that. I need to pass something from the calling
userform to tell userform10 which form is calling it, so that it knows
whether to do
JString = GlossaryForm4.ListBox1.Column(0)
or
JString = GlossaryForm3.ListBox1.Column(0)
or
JString = GlossaryForm11.ListBox1.Column(0)
Now, in C you would do something like, UserForm10.Show(UserForm3)
And in userform10, UserForm_Activate() would have a variable:
UserForm_Activate(UserForm)
That way, userform10 would know which userform was calling it, and would
look for listbox1 in that form.
Can you do that in VBA?
Any assistance appreciated.