VBA Not Working... at all?

How come the buttons work for you but not for me? I have copied the file onto a flash drive and tried it on a different machine (both before starting this thread and just now) and it still didn't work. I also tried unzipping the file that I posted and then using that copy. It still didn't work.

Then there's the fact that it worked on Thursday, didn't work on Sunday, worked yesterday when I used the break point (and after I cleared it), then didn't work today and still doesn't work after I inserted the break point or after I cleared it (I have even tried closing the entire file and opening it back up again).

I hate these situations. Unexplained computer problems that are only reproducible for the client, not the tech support.

Regarding the Save button: I know that moving to a new record autosaves, but in terms of how we will be using the database, a Save button is more intuitive on the user end. (It also saves us effort because we input some of the data at different times so saving is always good.)
 
Perhaps you do not have a Trusted Directory Location set in Access and silently VBA code is not being executed?
 
The "Event Address Same As Billing" and the "Event phone same as Billing" checks also have codes that were working (copying the information from the billing address and phone to the event address and phone).

I would change these to use the On_Click event. Then add code to that that looks something like:

Code:
Private Sub Check85_Click()

If Me.Check85 = True Then
    Me.[Event_Street] = Me.[Billing_Street]
    Me.[Event_City] = Me.[Billing_City]
    Me.[Event_State] = Me.[Billing_State]
    Me.[Event_Zip] = Me.[Billing_Zip]
else
    Me.[Event_Street] = ""
    Me.[Event_City] = ""
    Me.[Event_State] = ""
    Me.[Event_Zip] = ""
End If
End Sub
This way, each time the check box is clicked, if the value of the checkbox is true, then it will set the event info to the same as the billing info. If the checkbox is false, it will clear the event info. I'm assuming this is the behavior you're trying to obtain.

But with those I had noticed that the changes didn't come into effect until after I had a) moved to a new ID in the form or b) pressed the Save button near the bottom.

This:

Code:
Private Sub Command288_Click()
    If Me.Dirty Then    'Save any edits.
        Me.Dirty = False
    End If
End Sub
seems like an inelegant way of performing a save. I'd recommend:

Code:
Private Sub Command288_Click()
     DoCmd.RunCommand acCmdSaveRecord  
End Sub
The dirty property simply indicates if a record has been modified. One way of using the dirty property is to enable or disable a Save button based on the dirty property. So, if dirty = true, enable the save button. If dirty = false, disable the save button. This gives a visual indicator that changes need to be saved.

Hope that helps some.
 
Perhaps you do not have a Trusted Directory Location set in Access and silently VBA code is not being executed?

Yay! That worked! Now the test will be if it continues to work or goes FUBAR on me like it did between yesterday and today.


I would change these to use the On_Click event. Then add code to that that looks something like:


Code:
Private Sub Check85_Click() If Me.Check85 = True Then Me.[Event_Street] = Me.[Billing_Street] Me.[Event_City] = Me.[Billing_City] Me.[Event_State] = Me.[Billing_State] Me.[Event_Zip] = Me.[Billing_Zip] else Me.[Event_Street] = "" Me.[Event_City] = "" Me.[Event_State] = "" Me.[Event_Zip] = "" End If End Sub
I would change these to use the On_Click event. Then add code to that that looks something like:


Code:
Private Sub Check85_Click() If Me.Check85 = True Then Me.[Event_Street] = Me.[Billing_Street] Me.[Event_City] = Me.[Billing_City] Me.[Event_State] = Me.[Billing_State] Me.[Event_Zip] = Me.[Billing_Zip] else Me.[Event_Street] = "" Me.[Event_City] = "" Me.[Event_State] = "" Me.[Event_Zip] = "" End If End Sub


Both of those suggestions work perfectly, thank you!



[FONT=&quot]If you don't hear from me on this thread again than know that I am a happy camper. Thank you both for the help![/FONT]
 
If you don't hear from me on this thread again than know that I am a happy camper. Thank you both for the help!

You are very welcome, Reese. Thank you for coming back to confirm the victory result.
 

Users who are viewing this thread

Back
Top Bottom