Why this VBA does not work for some fields while it does for the o

G

Guest

Hello:

I want to make the default of the confirmation is No in the YesNo key,
because the tendency of people is just to hit enter while their purpose maybe
not to corrent. but
this VBA works for Exp Class field in my form, while it does not work for
Inovice Amount. Is that because of the type of the field si fifferent?, What
should I do.

I appceciate for any idea provided.

Thanks

Frank

Private Sub ExpClass_BeforeUpdate(Cancel As Integer)
If Not IsNull(Me.[ExpClass].OldValue) Then
If Me.[ExpClass] <> Me.[ExpClass].OldValue Then
If MsgBox("Anda telah merobah!!, apakah sengaja mau merobah?",
vbYesNo + vbDefaultButton2 + vbQuestion) = vbNo Then
' Undo the changes
SendKeys "{ESC}"
End If
End If
End If
End Sub

Private Sub Invoice_Amt_BeforeUpdate(Cancel As Integer)
If Not IsNull(Me.[Invoice Amt].OldValue) Then
If Me.[Invoice Amt] <> Me.[Invoice Amt].OldValue Then
If MsgBox("Anda telah merobah!!, apakah sengaja mau merobah?",
vbYesNo) = vbNo Then
' Undo the changes
SendKeys "{ESC}"
End If
 
G

geppo

Ciao "Frank Situmorang said:
Hello:

I want to make the default of the confirmation is No in the YesNo key,
because the tendency of people is just to hit enter while their purpose
maybe
not to corrent. but
this VBA works for Exp Class field in my form, while it does not work for
Inovice Amount. Is that because of the type of the field si fifferent?,
What
should I do.

I appceciate for any idea provided.

Thanks

Frank


Excuse, is Italian and I speaks little the English:

Private Sub ExpClass_BeforeUpdate(Cancel As Integer)
If Not IsNull(Me.[ExpClass].OldValue) Then
If Me.[ExpClass] <> Me.[ExpClass].OldValue Then
If MsgBox("Anda telah merobah!!, apakah sengaja mau merobah?",
vbYesNo + vbDefaultButton2 + vbQuestion) = vbNo Then
' Undo the changes
SendKeys "{ESC}"

Cancel = true
End If
End If
End If
End Sub

Private Sub Invoice_Amt_BeforeUpdate(Cancel As Integer)
If Not IsNull(Me.[Invoice Amt].OldValue) Then
If Me.[Invoice Amt] <> Me.[Invoice Amt].OldValue Then
If MsgBox("Anda telah merobah!!, apakah sengaja mau merobah?",
vbYesNo) = vbNo Then
' Undo the changes
SendKeys "{ESC}"

Cancel = true
 
G

Guest

Thankyou very much Geppo, Italian is still much better in English than us
Indonesian. Your suggegstion is very helpful and it works for me now.

Greetings from Jakarta, Indonesia

Frank

geppo said:
Ciao "Frank Situmorang said:
Hello:

I want to make the default of the confirmation is No in the YesNo key,
because the tendency of people is just to hit enter while their purpose
maybe
not to corrent. but
this VBA works for Exp Class field in my form, while it does not work for
Inovice Amount. Is that because of the type of the field si fifferent?,
What
should I do.

I appceciate for any idea provided.

Thanks

Frank


Excuse, is Italian and I speaks little the English:

Private Sub ExpClass_BeforeUpdate(Cancel As Integer)
If Not IsNull(Me.[ExpClass].OldValue) Then
If Me.[ExpClass] <> Me.[ExpClass].OldValue Then
If MsgBox("Anda telah merobah!!, apakah sengaja mau merobah?",
vbYesNo + vbDefaultButton2 + vbQuestion) = vbNo Then
' Undo the changes
SendKeys "{ESC}"

Cancel = true
End If
End If
End If
End Sub

Private Sub Invoice_Amt_BeforeUpdate(Cancel As Integer)
If Not IsNull(Me.[Invoice Amt].OldValue) Then
If Me.[Invoice Amt] <> Me.[Invoice Amt].OldValue Then
If MsgBox("Anda telah merobah!!, apakah sengaja mau merobah?",
vbYesNo) = vbNo Then
' Undo the changes
SendKeys "{ESC}"

Cancel = true
 
G

Guest

Geppo:

It does not work for my InvoiceDate field, should not it be " cancel as
INteger maybe?, is that the reason???. this is my VBA:
Private Sub InvoiceDate_BeforeUpdate(Cancel As Integer)
If Not IsNull(Me.[InvoiceDate].OldValue) Then
If Me.[InvoiceDate] <> Me.[InvoiceDate].OldValue Then
If MsgBox("Anda telah merobah!!, apakah sengaja mau merobah?",
vbYesNo + vbDefaultButton2 + vbQuestion) = vbNo Then
' Undo the changes
SendKeys "{ESC}"
Cancel = True
End If
End If
End If

End Sub

geppo said:
Ciao "Frank Situmorang said:
Hello:

I want to make the default of the confirmation is No in the YesNo key,
because the tendency of people is just to hit enter while their purpose
maybe
not to corrent. but
this VBA works for Exp Class field in my form, while it does not work for
Inovice Amount. Is that because of the type of the field si fifferent?,
What
should I do.

I appceciate for any idea provided.

Thanks

Frank


Excuse, is Italian and I speaks little the English:

Private Sub ExpClass_BeforeUpdate(Cancel As Integer)
If Not IsNull(Me.[ExpClass].OldValue) Then
If Me.[ExpClass] <> Me.[ExpClass].OldValue Then
If MsgBox("Anda telah merobah!!, apakah sengaja mau merobah?",
vbYesNo + vbDefaultButton2 + vbQuestion) = vbNo Then
' Undo the changes
SendKeys "{ESC}"

Cancel = true
End If
End If
End If
End Sub

Private Sub Invoice_Amt_BeforeUpdate(Cancel As Integer)
If Not IsNull(Me.[Invoice Amt].OldValue) Then
If Me.[Invoice Amt] <> Me.[Invoice Amt].OldValue Then
If MsgBox("Anda telah merobah!!, apakah sengaja mau merobah?",
vbYesNo) = vbNo Then
' Undo the changes
SendKeys "{ESC}"

Cancel = true
 
G

geppo

Ciao "Frank Situmorang said:
Geppo:

It does not work for my InvoiceDate field, should not it be " cancel as
INteger maybe?, is that the reason???. this is my VBA:
Private Sub InvoiceDate_BeforeUpdate(Cancel As Integer)
If Not IsNull(Me.[InvoiceDate].OldValue) Then
If Me.[InvoiceDate] <> Me.[InvoiceDate].OldValue Then
If MsgBox("Anda telah merobah!!, apakah sengaja mau merobah?",
vbYesNo + vbDefaultButton2 + vbQuestion) = vbNo Then
' Undo the changes
SendKeys "{ESC}"
Cancel = True
End If
End If
End If

End Sub

"geppo" wrote:


The code VBA is correct, therefore it has to work.

The problem is another.

The control "InvoiceDate" it is in partnership to the field of a chart?

Because if so it was it doesn't work.

p.s.: I use a translator to communicate, it forgives some errors.
 
G

Guest

Thanks very much Geppo, the problem is in the control property, somebody put
it to Locked is Yes, it should be No. Thanks again for your idea, it opened
my mind to look at the control property. Yes the field is linked to the
calender, in order to input the date, but that is not that caused the problem.

By the way in which area are you in Italy, I have been to Rome in the Year
of 2002, I have seen also the church in Vatican. I stayed at the Collosse
hotel if I am not mistaken. I still remember the meaning of the "Uchita"
means "exit" when I was in the airport.

Again for both of us, English is not our langguage so we have problems in
expressing our idea.

If you intend to come to Jakarta some day please let me know,maybe I can
help you.

Regards,

Frank

geppo said:
Ciao "Frank Situmorang said:
Geppo:

It does not work for my InvoiceDate field, should not it be " cancel as
INteger maybe?, is that the reason???. this is my VBA:
Private Sub InvoiceDate_BeforeUpdate(Cancel As Integer)
If Not IsNull(Me.[InvoiceDate].OldValue) Then
If Me.[InvoiceDate] <> Me.[InvoiceDate].OldValue Then
If MsgBox("Anda telah merobah!!, apakah sengaja mau merobah?",
vbYesNo + vbDefaultButton2 + vbQuestion) = vbNo Then
' Undo the changes
SendKeys "{ESC}"
Cancel = True
End If
End If
End If

End Sub

"geppo" wrote:


The code VBA is correct, therefore it has to work.

The problem is another.

The control "InvoiceDate" it is in partnership to the field of a chart?

Because if so it was it doesn't work.

p.s.: I use a translator to communicate, it forgives some errors.
 
A

AccessVandal via AccessMonster.com

Hi Frank,

It's not possible to prevent the user to press the Enter key with the builtin
message box. But you can do is to create a custom message box of your own
with the "OnKeyPress" event to lock the Enter keys.

Here's a site for you. It's version 97 but can be used on any new version.

http://mc-computing.com/Databases/MSAccess/CustomDialogBoxes.html

It's been sometime since you have abandon your last post on this.

Do a Debug.Print on "Me.[Invoice Amt]"and "Me.[Invoice Amt].OldValue" before
the "If Then" line.

Press Ctrl + g to view the results in the immediate window.

You don't have to use the square brackets if the control name does not have a
spacing or a reserved charactor.

Frank said:
Hello:

I want to make the default of the confirmation is No in the YesNo key,
because the tendency of people is just to hit enter while their purpose maybe
not to corrent. but
this VBA works for Exp Class field in my form, while it does not work for
Inovice Amount. Is that because of the type of the field si fifferent?, What
should I do.

I appceciate for any idea provided.

Thanks

Frank

Private Sub ExpClass_BeforeUpdate(Cancel As Integer)
If Not IsNull(Me.[ExpClass].OldValue) Then
If Me.[ExpClass] <> Me.[ExpClass].OldValue Then
If MsgBox("Anda telah merobah!!, apakah sengaja mau merobah?",
vbYesNo + vbDefaultButton2 + vbQuestion) = vbNo Then
' Undo the changes
SendKeys "{ESC}"
End If
End If
End If
End Sub

Private Sub Invoice_Amt_BeforeUpdate(Cancel As Integer)
If Not IsNull(Me.[Invoice Amt].OldValue) Then
If Me.[Invoice Amt] <> Me.[Invoice Amt].OldValue Then
If MsgBox("Anda telah merobah!!, apakah sengaja mau merobah?",
vbYesNo) = vbNo Then
' Undo the changes
SendKeys "{ESC}"
End If
 
A

AccessVandal via AccessMonster.com

PS. As for the SendKey method. You have to use Cancel method as the event has
a Cancel argument. You can still use the SendKey to clear the input.

Example: The button on click event does not have an argument, so you'll need
to use "Undo" or just simply do a "Exit Sub" in your "If Then" statements.
This will exit the event.

If controls do not match then
msgbox with Yes and No
If No Then
'clear input if you need to
Exit Sub ----'do nothing and exit event
Else
'do something
.....
I think the previous post by others may have confused you.
 
G

Guest

Thank you Vandal for your explanation, it helps me and enriches my knowledge.
In fact my expertise is Finance and Accounting, I only visit this forum when
my staffs find problems on the application that I developed for them to use.

Thanks,

Frank


AccessVandal via AccessMonster.com said:
Hi Frank,

It's not possible to prevent the user to press the Enter key with the builtin
message box. But you can do is to create a custom message box of your own
with the "OnKeyPress" event to lock the Enter keys.

Here's a site for you. It's version 97 but can be used on any new version.

http://mc-computing.com/Databases/MSAccess/CustomDialogBoxes.html

It's been sometime since you have abandon your last post on this.

Do a Debug.Print on "Me.[Invoice Amt]"and "Me.[Invoice Amt].OldValue" before
the "If Then" line.

Press Ctrl + g to view the results in the immediate window.

You don't have to use the square brackets if the control name does not have a
spacing or a reserved charactor.

Frank said:
Hello:

I want to make the default of the confirmation is No in the YesNo key,
because the tendency of people is just to hit enter while their purpose maybe
not to corrent. but
this VBA works for Exp Class field in my form, while it does not work for
Inovice Amount. Is that because of the type of the field si fifferent?, What
should I do.

I appceciate for any idea provided.

Thanks

Frank

Private Sub ExpClass_BeforeUpdate(Cancel As Integer)
If Not IsNull(Me.[ExpClass].OldValue) Then
If Me.[ExpClass] <> Me.[ExpClass].OldValue Then
If MsgBox("Anda telah merobah!!, apakah sengaja mau merobah?",
vbYesNo + vbDefaultButton2 + vbQuestion) = vbNo Then
' Undo the changes
SendKeys "{ESC}"
End If
End If
End If
End Sub

Private Sub Invoice_Amt_BeforeUpdate(Cancel As Integer)
If Not IsNull(Me.[Invoice Amt].OldValue) Then
If Me.[Invoice Amt] <> Me.[Invoice Amt].OldValue Then
If MsgBox("Anda telah merobah!!, apakah sengaja mau merobah?",
vbYesNo) = vbNo Then
' Undo the changes
SendKeys "{ESC}"
End If
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top