The trouble with assigning values to objects
The third in an occasional series of rants by Chris
Shepherd
For my third column I’d like to take a look at
the simple act of assigning a value to a field using VBA. Ahhh, simple stuff I
here you say.
So we want to change the value in a text box from command button. Simple we just
write some code like this:
Private Sub Command13_Click()
Me.FirstName.Text =
"Test"
End Sub |
The Trouble with Access is that when you run this
code you get the Oh so useful and user friendly message:

Which is the access way of saying "I know we
said we use Visual Basic but at this point we’d really like to do our own
thing". Someone please explain why do I have to move to a control to change
it ?
Luckily the solution to this (thanks to John
Hawkins)
is quite simple:
Private Sub Command13_Click()
Me.FirstName.Value =
"Test"
End Sub |
An easy fix I know but helpful none the less.
If you have any comments about this article or
would like to suggest other niggles with Access please Contact Chris
Shepherd
Chris Shepherd is a Technical Consultant working
for SCC in the UK. He is an MCP in Access, VB, Excel and is a fully paid up
member of the Access fan club.
|