Solved

MS Access saving a variable name within a string in a field

Posted on 2014-04-23
2
409 Views
Last Modified: 2014-04-24
Hi

I would like to save the name of a variable within a string saved in a field.  I would then like to retrieve the string value within a procedure and use the string/variable concatenation as if written in the procedure itself.

So for example...

Value saved in field = "There are " & varNumber & " days to go"

The procedure where used has a variable varNumber which has a value (eg 3)

The field value is then retrieved (via DLookup for example) and thus the string them reads...

There are 3 days to go


Is this possible and if so what is the correct syntax?

Many thanks
0
Comment
Question by:kenabbott
2 Comments
 
LVL 28

Accepted Solution

by:
omgang earned 500 total points
ID: 40018123
You can accomplish this by creating a Function to return the value of the variable.  You use the function call in the field

Function GetVariable() As Integer
   
    GetVariable = varNumber

End Function

Then in your field
"There are " & GetVariable() & " days to go"

OM Gang
0
 

Author Comment

by:kenabbott
ID: 40019675
Many thanks
0

Featured Post

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I had to do a bit of research to find the answer to this question so I thought I'd share my results.  Due to our outdated mainframe systems, we need to downgrade IE9 to IE8 in order to stay compatible.  We also needed to downgrade Java.  In order to…
It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

789 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question