If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
FieldName Variable in VBA
Working in Access VBA:
‘Where S1Speech is a field name in an Access 2007 table called SP ‘This 1st example works fine putting the value from S1Speech into the variable S1 Dim S1 as String S1= [S1Speech] ‘ These other 2 examples don’t work Example #2 Dim S1 as String Dim TXHolder as String TXHolder = S1Speech S1=[TXHolder] Example #3 Dim S1 as String Dim TXHolder as String TXHolder = [S1Speech] S1=TXHolder Is there a way to use a variable in a situation like this? Thanks -- Dennis |
#2
|
|||
|
|||
FieldName Variable in VBA
Dennis
You don't mention where this code is running. It would typically be used as code-behind-form, so your use of [S1Speech] is probably pointing at the FORM, not the table. If you need to peek into the table to get values, take a look at the DLookup() function. If you want to use code-behind-form, the field will need to be available in the form. Good luck! Regards Jeff Boyce Microsoft Access MVP -- Disclaimer: This author may have received products and services mentioned in this post. Mention and/or description of a product or service herein does not constitute endorsement thereof. Any code or pseudocode included in this post is offered "as is", with no guarantee as to suitability. You can thank the FTC of the USA for making this disclaimer possible/necessary. "denyoung" wrote in message ... Working in Access VBA: 'Where S1Speech is a field name in an Access 2007 table called SP 'This 1st example works fine putting the value from S1Speech into the variable S1 Dim S1 as String S1= [S1Speech] ' These other 2 examples don't work Example #2 Dim S1 as String Dim TXHolder as String TXHolder = S1Speech S1=[TXHolder] Example #3 Dim S1 as String Dim TXHolder as String TXHolder = [S1Speech] S1=TXHolder Is there a way to use a variable in a situation like this? Thanks -- Dennis |
Thread Tools | |
Display Modes | |
|
|