Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Why have Command Buttons Stopped Working?

Status
Not open for further replies.

amy3000

Technical User
Sep 25, 2000
59
US
I set up a form (I guess it would be a switchboard but I didn't use the switchboard manager)from which all the data entry forms could be opened and reports previewed. All of a sudden they don't work. There are no error messages. I can't even create new command buttons that work. The reports and forms seem fine. I know very little VBA (Still working on the last VBA problem I posted here but got sidetracked with a different database), so I'm not really sure if it looks right. But why would it not allow the creation of new command buttons? Thanks, Amy
 
Backup your database and then do a Compact and Repair. The mdb might be corrupted. Also, make sure you close out of all your vba code, otherwise, Access may keep the code in memory and you can use up all the memory on a Win 9X PC.
 
Definitely do the Compact/Repair, but I'm curious, are you getting an error message when you click on the buttons or when you try to make more. are you getting any error messages at all? Kyle [pc2]
 
I hate it when I have to ask what sounds to me like a really stupid question, but how do I close out all the VBA? Thanks.
 
He just means if you are using any object variables (tabledefs, recordsets, connections, querydefs, variants, forms, etc.) that they should have a corresponding:

Set VarName = Nothing

But since the only way you'll have these is to put them in yourself, and you're fairly new to VBA you probably don't have any, but it wouldn't hurt to look through any code you have. The easiest way to tell is in your Dim statement

Dim x as Integer
Dim str as String
Dim frm as Form

If you notice the Variable type "Form" isn't Blue, it's an object, so if you look at your code and you see a Dim statement without a Blue word at the end, you need a corresponding

Set (VariableNameHere) = Nothing Kyle [pc2]
 
Kyle, we must have posted at the same time. No, there are no error messages of any kind. I did do a backup and tried compact and repair but it's still the same. Amy
 
OK, take a look at the design of your form. Select one of your command buttons, look at the properties. Go to the Events tab and look for the line that starts with "OnClick"

What's in the line there...It should be a macro name if you're using macros or [EventProceedure] if you're using code... Kyle [pc2]
 
Hmmm, it doesn't say OnClick. This is what's here for one of the command buttons:


Private Sub cmdClosingsFQ_Click()
On Error GoTo Err_cmdClosingsFQ_Click

Dim stDocName As String

stDocName = "rptClosingAdultQ"
DoCmd.OpenReport stDocName, acPreview

Exit_cmdClosingsFQ_Click:
Exit Sub

Err_cmdClosingsFQ_Click:
MsgBox Err.Description
Resume Exit_cmdClosingsFQ_Click

End Sub
 
But in the design view of the form where you can bring up the properties box (not the code view) if you go to the events tab of the properties there should be

BeforeUpdate
AfterUpdate
etc...
OnClick [Event Proceedure]
etc...

is that there?

If it is then do me a favor and go back to the code view and click on the left of the line:
"Private Sub cmdClosingsFQ_Click()"
There should now be a red dot there and the line should be Red.

Now open the form and press that button... it should take you to the code, press F8 to move to the next line, go through the whole fuinction and see what happens... Kyle [pc2]
 
I did the above but nothing happened when I opened the form and clicked on the button.
 
The only thing I can think of is that the "[Event Proceedure]" line is missing. This is what tells Access to go look for the code, without it it will ignore any code you have. I haven't been able to find of picture of where you need to check for this, but if you've been to the Events tab on the Properties window, let me know and select the drop-down next to OnClick and select [Event Proceedure], now hit the button on the far right that looks like this: "...", if it takes you to the code it didn't run, then I'm stumped, if it takes you to a blank part of the page then we've got something... Kyle [pc2]
 
I know what you mean with [Event Procedure] and it looked fine. I did manage to make it work, I don't know why. I had created some other command buttons within a couple of the forms to go to a new record or to the last record. I tried deleting all of them and for some reason the switchboard buttons now work. I say this every time: I've come a long way but, man, there's a lot longer to go with this stuff. Thanks for your help. Access works in mysterious ways. Amy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top