PDA

View Full Version : Solved: error messege fire if condition isnt met after updat



Trevor
03-10-2008, 12:56 PM
I am trying to execute an error message after controle update if, the button that is click is not the [update record] button. the [update record button does valdation for null fields on first click and updates on dblclick.
I have tried just above my error message if[update record].event.ondblclick <> true then [msg]
but I get an error that the method is not found and highlghts my .event or . dblclick . here is my code;
Is it posable to do this without inserting this code into every button I want this code to exicute on?
Dim LComments As Variant
If IDNumber <> "" Then
LComments = DLookup("[Comments]", "VMSU-CLT", "[IDNumber] = """ & IDNumber & """")
If Me.Comments <> LComments Then
Me.[Previous_Record_Button].Enabled = False
Me.[Next_Record_Button].Enabled = False
Me.[Find Record Button].Enabled = False

Me.[Print_Record_Button].Enabled = False
Me.[New Call Button].Enabled = False
Me.[Command107].Enabled = False
If Me.[Update Record].event.ondblclick <> True Then
MsgBox "You have attempted to update Comments, please click the 'Update Record' button" & _
"to continue or the 'Stop' Button to exit and go back to the Clip Board", vbInformation, _
"Update Attempted... "
Else: Me.[Previous_Record_Button].Enabled = True
Me.[Next_Record_Button].Enabled = True
Me.[Find Record Button].Enabled = True

Me.[Print_Record_Button].Enabled = True
Me.[New Call Button].Enabled = True
Me.[Command107].Enabled = True
End If
End If
End If
End Sub

Carl A
03-10-2008, 01:28 PM
You will get more responses if you use VBA Tags. It is really not that difficult.
:old:

Trevor
03-10-2008, 06:17 PM
ok, so remove my messgebox from the after update, and place it where?, because I wan't the messge to only fire if the user tries to hit any button ther then the [update record] or [stop button]
(excuse me, my brain is a little fried I've got about 5 db's in 1 project)
so I know what you mean when you say use tags but I'm drawing a blank on how to impliment this
should i just put the tag on the button I want it to fire on , and leave the message where it is and just add If [controlname].tage = x then
[msg]
End If
?
I have another question, its stupid but haven't figured this out yet :(, to use an "or" operater and move the expression to the next line ie if [condion] or [condion] = true [Do somthing]
if i try if [condion] or _
[condion]
the compiler complains even if i try using & _ after my "or" . how can I use or and continue on the next line?
sorry if i confused or lost you in my tangent

Trevor
03-12-2008, 09:57 PM
improved by placing error message ondirty, if checkbox only option is after update

OTWarrior
03-14-2008, 08:12 AM
He means use vba tags on the forum when posting code.

What you mentioned in your last message, did it fix it?

Trevor
03-14-2008, 12:30 PM
oh I mis red/understood, here is the above code in tags;

Dim LComments As Variant
If IDNumber <> "" Then
LComments = DLookup("[Comments]", "VMSU-CLT", "[IDNumber] = """ & IDNumber & """")
If Me.Comments <> LComments Then
Me.[Previous_Record_Button].Enabled = False
Me.[Next_Record_Button].Enabled = False
Me.[Find Record Button].Enabled = False

Me.[Print_Record_Button].Enabled = False
Me.[New Call Button].Enabled = False
Me.[Command107].Enabled = False
If Me.[Update Record].event.ondblclick <> True Then
MsgBox "You have attempted to update Comments, please click the 'Update Record' button" & _
"to continue or the 'Stop' Button to exit and go back to the Clip Board", vbInformation, _
"Update Attempted... "
Else: Me.[Previous_Record_Button].Enabled = True
Me.[Next_Record_Button].Enabled = True
Me.[Find Record Button].Enabled = True

Me.[Print_Record_Button].Enabled = True
Me.[New Call Button].Enabled = True
Me.[Command107].Enabled = True
End If
End If
End If
End Sub

Trevor
03-17-2008, 10:55 AM
added , the above code in a private sub update And

Call Update ' to each button I want to use this code on
If Me.[print record button].Enabled = false Then GoTo Endd:
[code]
Endd:
End sub

Trevor
03-17-2008, 10:56 AM
added , the above code in a private sub update And

Call Update ' to each button I want to use this code on
If Me.[print record button].Enabled = false Then GoTo Endd:
[Code]
Endd:
End sub