variable on report

B

Bill H.

How do I get a global variable to appear on a report?

Using a textbox and assigning it the value doesn't work

For example, putting =[mVariable01] in the textbox's data field fails.

Thx.
 
D

Douglas J. Steele

Create a function that returns the value of the variable, and use the
function.
 
B

Bill H.

OK, an "obvious" error on my part. :)

In the global module, I added:
Public Function fWorkshopName(mWorkshopName) as String
fWorkshopName = mWorkshopName
End Function

then on the data field of the textbox on the form, I put

=fworkshopname([mworkshopname])

But no go. I get an "invalid use of null" on the function assignment when I
try to open the report.

Where's my problem?

Thx.



Douglas J. Steele said:
Create a function that returns the value of the variable, and use the
function.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


in message
How do I get a global variable to appear on a report?

Using a textbox and assigning it the value doesn't work

For example, putting =[mVariable01] in the textbox's data field fails.

Thx.
 
D

Douglas J. Steele

mWorkshopName is a public variable: you don't have to pass it to the
function.

Public Function fWorkshopName() as String
fWorkshopName = mWorkshopName
End Function

and then use

=fWorkshopName()

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Bill H. said:
OK, an "obvious" error on my part. :)

In the global module, I added:
Public Function fWorkshopName(mWorkshopName) as String
fWorkshopName = mWorkshopName
End Function

then on the data field of the textbox on the form, I put

=fworkshopname([mworkshopname])

But no go. I get an "invalid use of null" on the function assignment when
I
try to open the report.

Where's my problem?

Thx.



Douglas J. Steele said:
Create a function that returns the value of the variable, and use the
function.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


in message
How do I get a global variable to appear on a report?

Using a textbox and assigning it the value doesn't work

For example, putting =[mVariable01] in the textbox's data field fails.

Thx.
 
B

Bill H.

OK, making progress.

How do I account for a null value in the function?

For example, two of the functions are date type. Sometimes, the date has
not input, resulting in the public variable being assigned a Null value.

Thx.

Douglas J. Steele said:
mWorkshopName is a public variable: you don't have to pass it to the
function.

Public Function fWorkshopName() as String
fWorkshopName = mWorkshopName
End Function

and then use

=fWorkshopName()

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Bill H. said:
OK, an "obvious" error on my part. :)

In the global module, I added:
Public Function fWorkshopName(mWorkshopName) as String
fWorkshopName = mWorkshopName
End Function

then on the data field of the textbox on the form, I put

=fworkshopname([mworkshopname])

But no go. I get an "invalid use of null" on the function assignment when
I
try to open the report.

Where's my problem?

Thx.



Douglas J. Steele said:
Create a function that returns the value of the variable, and use the
function.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


in message
How do I get a global variable to appear on a report?

Using a textbox and assigning it the value doesn't work

For example, putting =[mVariable01] in the textbox's data field fails.

Thx.
 
D

Douglas J. Steele

Public Function fWorkshopName() as String
fWorkshopName = Nz(mWorkshopName, "No known value")
End Function


--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


Bill H. said:
OK, making progress.

How do I account for a null value in the function?

For example, two of the functions are date type. Sometimes, the date has
not input, resulting in the public variable being assigned a Null value.

Thx.

Douglas J. Steele said:
mWorkshopName is a public variable: you don't have to pass it to the
function.

Public Function fWorkshopName() as String
fWorkshopName = mWorkshopName
End Function

and then use

=fWorkshopName()

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Bill H. said:
OK, an "obvious" error on my part. :)

In the global module, I added:
Public Function fWorkshopName(mWorkshopName) as String
fWorkshopName = mWorkshopName
End Function

then on the data field of the textbox on the form, I put

=fworkshopname([mworkshopname])

But no go. I get an "invalid use of null" on the function assignment when
I
try to open the report.

Where's my problem?

Thx.



message
Create a function that returns the value of the variable, and use the
function.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


in message
How do I get a global variable to appear on a report?

Using a textbox and assigning it the value doesn't work

For example, putting =[mVariable01] in the textbox's data field fails.

Thx.
 
B

Bill H.

That looks good.

What I ended up doing was declaring the two DATE variables as STRING
instead. That allowed a null value. :)

Funny how a date type variable with no contents is not null.


Douglas J. Steele said:
Public Function fWorkshopName() as String
fWorkshopName = Nz(mWorkshopName, "No known value")
End Function


--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


"Bill H." wrote in message
OK, making progress.

How do I account for a null value in the function?

For example, two of the functions are date type. Sometimes, the date has
not input, resulting in the public variable being assigned a Null value.

Thx.

Douglas J. Steele said:
mWorkshopName is a public variable: you don't have to pass it to the
function.

Public Function fWorkshopName() as String
fWorkshopName = mWorkshopName
End Function

and then use

=fWorkshopName()

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


OK, an "obvious" error on my part. :)

In the global module, I added:
Public Function fWorkshopName(mWorkshopName) as String
fWorkshopName = mWorkshopName
End Function

then on the data field of the textbox on the form, I put

=fworkshopname([mworkshopname])

But no go. I get an "invalid use of null" on the function assignment when
I
try to open the report.

Where's my problem?

Thx.



message
Create a function that returns the value of the variable, and use the
function.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


in message
How do I get a global variable to appear on a report?

Using a textbox and assigning it the value doesn't work

For example, putting =[mVariable01] in the textbox's data field fails.

Thx.
 
D

Douglas J. Steele

Um, string variables can't be Null: only Variants can be.

A Date is simply a numeric field (it's an 8 byte floating point number,
where the integer portion represents the date as the number of days relative
to 30 Dec, 1899, and the decimal portion represents the time as a fraction
of a day). The default value for all numeric fields is 0.

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


Bill H. said:
That looks good.

What I ended up doing was declaring the two DATE variables as STRING
instead. That allowed a null value. :)

Funny how a date type variable with no contents is not null.


Douglas J. Steele said:
Public Function fWorkshopName() as String
fWorkshopName = Nz(mWorkshopName, "No known value")
End Function


--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


"Bill H." wrote in message
OK, making progress.

How do I account for a null value in the function?

For example, two of the functions are date type. Sometimes, the date has
not input, resulting in the public variable being assigned a Null
value.

Thx.

message
mWorkshopName is a public variable: you don't have to pass it to the
function.

Public Function fWorkshopName() as String
fWorkshopName = mWorkshopName
End Function

and then use

=fWorkshopName()

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


OK, an "obvious" error on my part. :)

In the global module, I added:
Public Function fWorkshopName(mWorkshopName) as String
fWorkshopName = mWorkshopName
End Function

then on the data field of the textbox on the form, I put

=fworkshopname([mworkshopname])

But no go. I get an "invalid use of null" on the function
assignment
when
I
try to open the report.

Where's my problem?

Thx.



message
Create a function that returns the value of the variable, and use the
function.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


in message
How do I get a global variable to appear on a report?

Using a textbox and assigning it the value doesn't work

For example, putting =[mVariable01] in the textbox's data field
fails.

Thx.
 

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