How to return values - best solution ?

  • Thread starter Thread starter adamk
  • Start date Start date
A

adamk

Hi,

How can I return values (to setup some controls e.g. txtBox) to calling form
from called form when I don't know the name of the calling form ?



Thanks for any help

Adam
 
hi Adam,
How can I return values (to setup some controls e.g. txtBox) to calling form
from called form when I don't know the name of the calling form ?
Your description is pretty vague.

You normally return values either as a function result or an out
parameter of any method.

If you have to setup controls, you may use something like:

Option Compare Database
Option Explicit

Public Sub SetupTextBox(ATextBox As Access.TextBox)

ATextBox.Color = RGB(133,133,133)
ATextBox.Value = "Test"

End Sub

and call it later where you need it.


mfG
--> stefan <--
 
Adam

We have even less to go on than you do ...

Have you looked into using a global variable?  Or the OpenArgs property?

--
Regards

Jeff Boycewww.InformationFutures.net

Microsoft Office/Access MVPhttp://mvp.support.microsoft.com/

Microsoft IT Academy Program Mentorhttp://microsoftitacademy.com/

Sorry :-) More detailed description follows.

Form Form1 has two controls:
- text box control - Text1
- button control - Button1
Form Form2 is classic datasheet form e.g. Customers.

In OnClickEvent for Button1 control I open Form2 to select valeues
(from 1 selected row).

Value(s) from selected row on Form2 (e.g. CustomerFirstName) I want to
assign to Text1 control on Form1.

Because of I create some "template" form I don't want to use "direct"
name of the calling form (Form1) and "direct" name of the text
control.

The best solution will be passing them as "parameters".

I looked into using a global variables and the OpenArgs property, but
all of them used "direct" names.


Adam
 
I still don't have a very clear picture of your underlying data structure,
and in Access, it all starts with the data!

It might be that you have a one-to-many relationship between two sets of
data (?tables). If so, consider using the main form/subform design, built
specifically to handle what I believe you are describing...

--
Regards

Jeff Boyce
www.InformationFutures.net

Microsoft Office/Access MVP


Microsoft IT Academy Program Mentor
http://microsoftitacademy.com/

Adam

We have even less to go on than you do ...

Have you looked into using a global variable? Or the OpenArgs property?

--
Regards

Jeff Boycewww.InformationFutures.net

Microsoft Office/Access MVPhttp://mvp.support.microsoft.com/

Microsoft IT Academy Program Mentorhttp://microsoftitacademy.com/

Sorry :-) More detailed description follows.

Form Form1 has two controls:
- text box control - Text1
- button control - Button1
Form Form2 is classic datasheet form e.g. Customers.

In OnClickEvent for Button1 control I open Form2 to select valeues
(from 1 selected row).

Value(s) from selected row on Form2 (e.g. CustomerFirstName) I want to
assign to Text1 control on Form1.

Because of I create some "template" form I don't want to use "direct"
name of the calling form (Form1) and "direct" name of the text
control.

The best solution will be passing them as "parameters".

I looked into using a global variables and the OpenArgs property, but
all of them used "direct" names.


Adam
 
I still don't have a very clear picture of your underlying data structure,
and in Access, it all starts with the data!

It might be that you have a one-to-many relationship between two sets of
data (?tables).  If so, consider using the main form/subform design, built
specifically to handle what I believe you are describing...

--
Regards

Jeff Boycewww.InformationFutures.net

Microsoft Office/Access MVPhttp://mvp.support.microsoft.com/

Microsoft IT Academy Program Mentorhttp://microsoftitacademy.com/








Sorry :-) More detailed description follows.

Form Form1 has two controls:
- text box control - Text1
- button control - Button1
Form Form2 is classic datasheet form e.g. Customers.

In OnClickEvent for Button1 control I open Form2 to select valeues
(from 1 selected row).

Value(s) from selected row on Form2 (e.g. CustomerFirstName) I want to
assign to Text1 control on Form1.

Because of I create some "template" form I don't want to use "direct"
name of the calling form (Form1) and "direct" name of the text
control.

The best solution will be passing them as "parameters".

I looked into using a global variables and the OpenArgs property, but
all of them used "direct" names.

Adam Hi,

I still don't have a very clear picture of your underlying data structure,
and in Access, it all starts with the data!
You are right, the data is DB2.
To connect to DB2 I use ODBC - Access is only my front-end.

Form1 is modal and all controls are unbound.

I'm using pass-through queries. By the big count of records in DB2
tables I can't use ComboBox'es or ListBox'es to choose value for text
box control - Text1.

I decide to use Form2 (classic datasheet form) to allow user choose
Customer.
When user select Customer on Form2 I want to assing values to Text1
control on Form1.


Sorry for my bad English :-(((
 
Adam

Even if there are large numbers of records in your data source, you might
still be able to use a combobox. Take a look at the results of an on-line
search for "Cascading Comboboxes". The general idea is to use one combobox
first to narrow the number of records (e.g., all names starting with "A"),
then use a second combobox that relies on the value in the first to display
a (considerably) reduced list of possible records.

Good luck!

--
Regards

Jeff Boyce
www.InformationFutures.net

Microsoft Office/Access MVP


Microsoft IT Academy Program Mentor
http://microsoftitacademy.com/

I still don't have a very clear picture of your underlying data structure,
and in Access, it all starts with the data!

It might be that you have a one-to-many relationship between two sets of
data (?tables). If so, consider using the main form/subform design, built
specifically to handle what I believe you are describing...

--
Regards

Jeff Boycewww.InformationFutures.net

Microsoft Office/Access MVPhttp://mvp.support.microsoft.com/

Microsoft IT Academy Program Mentorhttp://microsoftitacademy.com/









Sorry :-) More detailed description follows.

Form Form1 has two controls:
- text box control - Text1
- button control - Button1
Form Form2 is classic datasheet form e.g. Customers.

In OnClickEvent for Button1 control I open Form2 to select valeues
(from 1 selected row).

Value(s) from selected row on Form2 (e.g. CustomerFirstName) I want to
assign to Text1 control on Form1.

Because of I create some "template" form I don't want to use "direct"
name of the calling form (Form1) and "direct" name of the text
control.

The best solution will be passing them as "parameters".

I looked into using a global variables and the OpenArgs property, but
all of them used "direct" names.

Adam Hi,

I still don't have a very clear picture of your underlying data structure,
and in Access, it all starts with the data!
You are right, the data is DB2.
To connect to DB2 I use ODBC - Access is only my front-end.

Form1 is modal and all controls are unbound.

I'm using pass-through queries. By the big count of records in DB2
tables I can't use ComboBox'es or ListBox'es to choose value for text
box control - Text1.

I decide to use Form2 (classic datasheet form) to allow user choose
Customer.
When user select Customer on Form2 I want to assing values to Text1
control on Form1.


Sorry for my bad English :-(((
 
Back
Top