RESOLVED - Using variables to acquire form data
Hello all,
I'm building a database system in Access 2002 and one of the functions I want to program into it has become a bit of a stumbling block. Unfortunately I have not been able to find details on doing what I want, mainly because I can't think how to word it in search engines.
In brief, the situation I have is this:
I currently have a table with VBA code which populates a variable with a string and form data:
This is passed to a function in a code module in order to generate an e-mail. The e-mail subject line then substitutes & CustomerName with the contents of the CustomerName field on the currently open form.
The code works fine at the moment, but I want to get away from having these variables hard coded. My hope is that the table I have created can be used to populate these variables in order to make changes easy for the end user.
The table has a text field which contains the same text as was added to the variable in the above code box.
The problem that I have is that by using the code:
I end up with with it passing the data to the function as is, so the subject line then just displays "Asset Information - " & CustomerName (rather than substituting the data in the field CustomerName.
Is there any way of having VBA recognise that I want it to use the contents of the field on the table as a command rather than copy it as a string.
Any help would be greatly appreciated.
Damion.
Hello all,
I'm building a database system in Access 2002 and one of the functions I want to program into it has become a bit of a stumbling block. Unfortunately I have not been able to find details on doing what I want, mainly because I can't think how to word it in search engines.
In brief, the situation I have is this:
I currently have a table with VBA code which populates a variable with a string and form data:
Code:
varSubject = "Asset Information - " & CustomerName
This is passed to a function in a code module in order to generate an e-mail. The e-mail subject line then substitutes & CustomerName with the contents of the CustomerName field on the currently open form.
The code works fine at the moment, but I want to get away from having these variables hard coded. My hope is that the table I have created can be used to populate these variables in order to make changes easy for the end user.
The table has a text field which contains the same text as was added to the variable in the above code box.
The problem that I have is that by using the code:
Code:
varSubject = DLookup("SubjectLine", "gblSysLaptopSwaps", "ControlRef = 2")
I end up with with it passing the data to the function as is, so the subject line then just displays "Asset Information - " & CustomerName (rather than substituting the data in the field CustomerName.
Is there any way of having VBA recognise that I want it to use the contents of the field on the table as a command rather than copy it as a string.
Any help would be greatly appreciated.
Damion.
Last edited: