Switchboard button disabled

Mac_Wood

Registered User.
Local time
Today, 22:19
Joined
Dec 10, 2005
Messages
65
Hi Guys,
This is my first post on what seems to be a popular and informative site.

I have a database which contains Maintenance Records for vehicles and machinery. One of the tables contains details of service information. When the database opens I have a piece of code which checks this table for any incomplete or overdue services and if necessary displays a pop up window asking if the user wishes to see these. My problems are if I click No the default switchboard which I am left with which contains 7 buttons has one button which is disabled this points to a second switchboard which will display reports, if I click Yes all buttons work. If there are no records to display the switchboard contains this disabled button:confused:

Thanks in advance for your help
 
Are you talking about the Switchboard form that the switchboard manager builds? Did you modify its code in any way? Did you modify the switchboard items table in any way?
 
Yes it is. The piece of code that brings up the pop up reminder I originally added to the OnLoad event procedure but this produced a runtime error 2001. I then added it to the OnOpen procedure as this had been created when the switchboard was created. I also edited the switchboard via the switchboard manager but not the switchboard items table.
 
To tell if your code caused the problem, you'll need to recreate the original switchboard table.
1. rename the Switchboard Items table to SaveSwitchboard Items.
2. rename the current switchboard form to SaveSwitchboard.
3. open the switchboard manager. It will tell you it doesn't find a switchboard which is exactly what you want.
4. don't bother entering any items. Just close the switchboard manager.
5. delete the Switchboard Items table (it should have only one row)
6. rename SaveSwitchboard Items back to Switchboard Items.
7. open the new switchboard form. Do you have the same problem? If not, your code in the other form broke it.
 
Thanks Pat I'll try your suggestions when I get back to work. In the meantime I have a copy of the database at home with which I'm also having problems. I'm getting a runtime error 2001 you cancelled the previous operation, and the debuigger highlights the following code:

Code:
intStore = DCount("[ServiceRecordID]", "ServiceRecords", "[ServiceCompleted] <=Now() AND [Complete] =0")

I have searched this site for an answer but with my limited knowledge of VBA none of the related topics seem to answer my problem.

Thanks for your help:o
 
That error sometimes doesn't have anything to do with the actual error. So I don't have any suggestions.

However, you should not use Now() when you really mean Date(). Your results will be incorrect in certain cases due to the time-of-day component of Now().
 
can you post the rest of the code that goes with that line?

Peter
 
Rest of the code

Hope you can find something Peter

Code:
'On Load of the switchboard check Jobs table for any uncompleted jobs

Dim intStore As Integer

'Count of uncomplete jobs that are past the Expected Completion Date
intStore = DCount("[ServiceRecordID]", "ServiceRecords", "[CurrentServiceCompleted] <=Now() AND [Complete] =0")

'If count of uncomplete jobs is zero display switchboard
'Else display message box detailing amount of jobs
'and give the user the option as to whether to view these or not.
    If intStore = 0 Then
            Exit Sub
                Else
                    If MsgBox("There are " & intStore & " uncompleted jobs" & _
                    vbCrLf & vbCrLf & "Would you like to see these now?", _
                    vbYesNo, "You Have Uncomplete Jobs...") = vbYes Then
                    DoCmd.Minimize
                    DoCmd.OpenForm "frmReminders", acNormal
                Else
            Exit Sub
        End If
    End If
End Sub
 
I have tried your code, just substituting table/filed names and it works no problem.

I am using A2K on W2K

Have you tried Compact and Repair in case something wacky has crept in?

Also might be worth checking in any module Tools/References... and make sure that none are marked as 'missing' as that can cause odd errors.

Not much else to suggest I'm afraid. You could try the code in a standard form and make sure it works OK there. try remming it out in switchboad and make sure the switchboard works OK without it.

peter
 
Thanks Pat for your suggestions. Although my interpretation of what you suggested didn't work I removed the offending button and the code worked fine so it must have been my editing of the switchboard which caused the problem. On my copy of the database the problem seems to have been with the DLookup as pointed out by the debugger I was asking the code to look up a date from a Yes/No field :o so everything's working great now. Peter thanks also for your suggestions, one thing I learnt is to regularly compact and repair databases.
 

Users who are viewing this thread

Back
Top Bottom