andrewb
andrewb

Reputation: 5339

Problems implementing basic VBA in Access 2007

I'm trying to write some code for my database to enable a dropdown box in a parameter prompt for a query, but it's doing nothing instead of it's intended purpose. This:

Dropdown in Access 2007 parameter query

has been the source of my inspiration. Though I seem to be unable to implement even the most basic VBA code:

  Private Sub cmdReset_Click()
    Me.cboSelectName = Null
  End Sub

(Yes this is not all my code! Just one of the subs)

On the relevant form, I have a button called "cmdReset", which has "[Event Procedure]" for the event "On-Click". I also have a dropdown box called "cboSelectName" on said form. Also I have tried closing the database, and making sure to enable macros when it starts.

So essentially this code should make the value in the dropdown box null when I click the reset button. However it does nothing, it simply deselects the dropdown box. Can anyone help me with this one? I'm keen to start implementing some VBA in my database!

Upvotes: 2

Views: 582

Answers (1)

andrewb
andrewb

Reputation: 5339

As suggested by Remou, the code wasn't even running. I figured out my problem - I had saved the code in a new module, rather than in the VBA code for my form. Once I shifted the code into the form object, the reset button worked. I've also now got some nifty code working with the actual "generate report" command. VBA really has the power to take your database to a whole new level!

Upvotes: 1

Related Questions