PDA

View Full Version : Any reasons why my buttons work on one workstation and not on another??



wedd
01-13-2011, 05:00 AM
Hi, I created a few buttons on my form on my home computer which works, however when I try the buttons on my workstation at work the buttons do not work. Do you have any reasons why this happens? Would you have any slotuions to resolve this issue?



Thanks for your contributions!:friends:

SoftwareMatt
01-13-2011, 05:58 AM
Are you definitely using the same front and linking to a copy of the back with the same records in?

If yes then it might help if you post what the buttons are doing i.e. the code.

wedd
01-13-2011, 01:23 PM
Software Matt, this is the code to a save button I created. It works on my workstation but doesn't on my workstation at work.

Private Sub Command21_Click()
Dim strMsg As String
Dim iResponse As Integer
' Specify the message to display.
strMsg = "Do you wish to save the changes?" & Chr(10)
strMsg = strMsg & "Click Yes to Save or No to Discard changes."
' Display the message box.
iResponse = MsgBox(strMsg, vbQuestion + vbYesNo, "Save Record?")

' Check the user's response.
If iResponse = vbNo Then
' Undo the change.
DoCmd.RunCommand acCmdUndo
' Cancel the update.
Cancel = True
End If
End Sub

hansup
01-13-2011, 07:46 PM
What is the purpose of this line in your subroutine?
Cancel = True
Add Option Explicit to the Declarations section of your form's module.

Also, in the VBE editor, choose Tools->Options from the main menu. Then place a check mark next to "Require Variable Declaration" on the "Editor" tab, and click OK. Afterwards, any new modules you create will automatically include Option Explicit. You should also add Option Explicit to all your existing modules. And get in the habit of running Debug->Compile from the main menu, especially when you're trying to troubleshoot a problem.

With that issue out of the way, what is your code intended to do when "it works" on your home machine? It will undo changes to the current record if the user responds No. However, if the user responds Yes, nothing happens ... your code does not save any changes to the current record.

Please tell us specifically what happens when "it works" at home, and when "it doesn't work" at work.

wedd
01-17-2011, 02:30 AM
hansup, at home I receive a message "Do you want to save this record?" At work when I click on the save button the message doesn't appear. The purpose of the cancel = true subroutine is if the user decides he doesn't wont to choose either option to save or not save the record.

hansup
01-17-2011, 08:47 AM
hansup, at home I receive a message "Do you want to save this record?"
Where does that message come from? According to your code, the message box prompt should be:
"Do you wish to save the changes?
Click Yes to Save or No to Discard changes."

At home, if you make a change to the current record in the form, then click your save button and respond Yes, does the change get saved in the record source table? I don't see how it can with the code you posted.


At work when I click on the save button the message doesn't appear.
Does any VBA code run in your application at work? If your Access version at work is 2007 or 2010, you need to run the application from a Trusted Location or digitally sign the application in order for Access to run the VBA.


The purpose of the cancel = true subroutine is if the user decides he doesn't wont to choose either option to save or not save the record.Have you declared a variable named "Cancel" somewhere else in your code? If not, I think the debugger will complain it can't find a variable named Cancel. Note that assumes you've added Option Explicit to the Declarations section of your form's module as I suggested previously. Have you done that? And then run Debug->Compile from the VBE main menu?

wedd
01-17-2011, 10:30 AM
Yes, I've used option explicit and ran the debug. It could also be possible that access application isn't set to run from a trusted location. Thanks!

wedd
01-17-2011, 10:31 AM
Thanks!

hansup
01-17-2011, 12:26 PM
Yes, I've used option explicit and ran the debug. What happens on your system when you run debug?

I pasted your code into a new form module which includes Option Explicit, and Debug->Compile gives me a compile error: "Variable not defined" with Cancel highlited.

wedd
01-17-2011, 12:29 PM
Same thing happened to me to. I deleted the variable cancel and ran a test again and the error didn't reoccur. I clicked on no button to test that event and I also didn't receive an error message.

wedd
01-17-2011, 12:36 PM
Hansup, I ran a test to save the records by clicking yes. If the records have been saved correctly through the code should a pop up message display records have been saved, afterwards?

hansup
01-17-2011, 12:52 PM
Hansup, I ran a test to save the records by clicking yes. If the records have been saved correctly through the code This will be the last time I tell you this ... the code you showed us does nothing to save the current record.