Public Variables and Table Values

G

Gordon Dale

I need to set a TextBox.Text with a variable loaded from
a Table called [Project Details].[JobNo]

I have tried loading from the Sub directly using
TextBox.Text = [Project Details].[JobNo] but had lots of
different compile error messages so I tried 'Public
JobNumber as String' but as there are a numebr of modules
in my project (as well as forms) if I declare the
variable as Public in more than one module it is in
effect a different variable in each module therefore its
value is overwritten.

In short how can I either load the text box direct from
the table or declare a truly public variable and assign a
value I can use on any form within my project?

I would appreciate some guidance

I anticipation

Gordon
 
M

Marshall Barton

Gordon said:
I need to set a TextBox.Text with a variable loaded from
a Table called [Project Details].[JobNo]

I have tried loading from the Sub directly using
TextBox.Text = [Project Details].[JobNo] but had lots of
different compile error messages so I tried 'Public
JobNumber as String' but as there are a numebr of modules
in my project (as well as forms) if I declare the
variable as Public in more than one module it is in
effect a different variable in each module therefore its
value is overwritten.

In short how can I either load the text box direct from
the table or declare a truly public variable and assign a
value I can use on any form within my project?


Typically, you would open a recordset on a query that
selected the desired record, then copy the fields to some
text boxes.

On the other hand, if you only want a single value, you can
use the DLookup function to retrieve the field's value:

Me.TextBox = DLookup("JobNo", "Project Details")
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top