I have a form that i want to run logging on, the form has a navigation strip, so if you got to add new from there, it will automaticly add a record, i want to cancel that and make sure the user has to click my save button, how can i do this?
The only reason to select a Save would be if the user actually entered or modified a record. With that in mind, you could do this:
Delcare a Variable in the declarations section of your Form (under Option Explicit). Let's call it ByPass
Dim ByPass As Integer
This will make the variable Public to all Code in that Form only.
In your Save button's OnClick event, enter this line:
ByPass = 1
This will indicate to to any code in Form that the Save button WAS selected.
Now in the Form's BeforeUpdate event, Copy and paste this:
'Check the ByPass integer variable. If it contains 1 then reset it
'to 0 and skip the Dirty check since we now that the Save button
If ByPass = 1 Then ByPass = 0: Exit Sub
'If someone has edited anywhere within the record then the Form's
'Dirty property becomes True. If we read this property we can then
'therefore determine that changes of sorts have been made and we
'now want the User to Select the Save button. Let's inform them of
'Check the Form's Dirty property...
If Me.Dirty = True Then
'Because we know the ByPass variable is 0 (since we managed
'to get this far) let's inform the User to select the Save Button.
MsgBox "You have made changes to this record. Please select" & vbCr & _
"the save button before moving on. Thank You.", vbExclamation, _
"Please Select Save Button"
'Cancel the Form from moving off record.
Cancel = True
Sumthin like that....
Self Taught In ALL Environments.....And It Shows!