Easy VBA Question that need answer

  • Thread starter Thread starter Troy
  • Start date Start date
T

Troy

Hello,

My boss asked or has given me these 11 questions he wants answered by
tomorrow and I was hoping you pros could help me out real quick. I am a new
developer (2 months) and I am not into VBA as of yet. I cant find the
answers to the remaining questions.

PLEASE HELP!

1. What built in object would you use to execute Macro commands from VBA
code?

2. If you want to write your own custom validation function for a control,
what event would you attach to this?

3. What form property would you set to write cached data to the underlying
table?

4. What must you include in the declaration of an object in order for it to
trigger events?

5. In VBA, is it possible to use a For Each ... next loop with your own
collection class? Why?

Thank any of you that can get me the answers to these questions or direct me
to where I can find them ASAP.
 
Answers in-line.

Is this actually *homework* ? :-(


Troy said:
Hello,

My boss asked or has given me these 11 questions he wants answered by
tomorrow and I was hoping you pros could help me out real quick. I am a new
developer (2 months) and I am not into VBA as of yet. I cant find the
answers to the remaining questions.

PLEASE HELP!

1. What built in object would you use to execute Macro commands from VBA
code?
No comment. I know nix about macros. erhaps check "RunCommand" in online
help.
2. If you want to write your own custom validation function for a control,
what event would you attach to this?
You would not attach an event to anything. You would write your validation
code in the BeforeUpdate event procedure.
3. What form property would you set to write cached data to the underlying
table?
There is no such property. Access & Jet will do this for you. There is a
relevant option on the Commit statement (I think - but I don't have Access
here to check), but in no way could that be described as a "form property".
4. What must you include in the declaration of an object in order for it
to trigger events?
There is a "with events" declaration in VB, but I'm not sure what it does,
or whether it exists in any version of Access VBA.
5. In VBA, is it possible to use a For Each ... next loop with your own
collection class? Why?
What on earth do you mean by the "Why?" ?
If it's possible - it's possible! If it isn't - it isn't!
Certainly it is possible in VBA to use a For Each loop with a Collection
object (dim mycoll as collecion). Is that what you mean?
Thank any of you that can get me the answers to these questions or direct
me to where I can find them ASAP.
 
I know it sounds like homework but it is not. I thought
people would think that. But I have on hell of a scatter
brain boss. He makes no sense at all. Kind of tough if I
dont know what I am doing either in the development area!
 
1. DoCmd object, RunMacro method.

2. The control's BeforeUpdate event. You could also go back at the end of typing
everything in and do this in the Form's BeforeUpdate event, checking all the controls on
the form at one time.

3. I believe he is looking for the Dirty property of the Form. If the Form is dirty
(changes have been made to the record), setting Dirty = False will write them to the
table.

4. From the help file, this will allow it to respond to events, not trigger them. There
may be something else he is looking for, I don't know.

"WithEvents - Optional. Keyword that specifies that varname is an object variable used to
respond to events triggered by an ActiveX object. WithEvents is valid only in class
modules. You can declare as many individual variables as you like using WithEvents, but
you can't create arrays with WithEvents. You can't use New with WithEvents."

5. This item from the help file may be what he is looking for here. "You can't use the
For...Each...Next statement with an array of user-defined types because a Variant can't
contain a user-defined type."
 
Back
Top