Risk in using combo

F

Frank Situmorang

Hello:

I have an input form using combo, but it could happen the users or other
people hit again the arrow head and choose another choice and the record was
updated wrongly. My question is how can we avoide that people unintentionally
modify the data say " supplier name". I know that there is something to
change in the event property. But I do not really know how to make it. But
again there is a situation that we intentionally need to change the data "
supplier name " because we input it wrongly.

Thank you,

Frank
 
O

Ofer Cohen

In the Combo BeforeUpdate event you can write the code if the data was
changed, if so ask the user if he/she want to save it

If Not IsNull(Me.[ComboName].OldValue) Then
If Me.[ComboName]<> Me.[ComboName].OldValue Then
If MsgBox("The value was changed, Would you like to undo the
changes?", vbYesNo) = vbYes Then
' Undo the changes
SendKeys "{ESC}"
End If
End If
End If
 
F

Frank Situmorang

Ofer, you help me a lot, Thank you very much, I will try to do it now, but I
think again, that it is good also for another field, like Inv# and amount
field, is there any similar method like you gave me to be put in other fields
other than combo?

Thanks in advance

Frank

Ofer Cohen said:
In the Combo BeforeUpdate event you can write the code if the data was
changed, if so ask the user if he/she want to save it

If Not IsNull(Me.[ComboName].OldValue) Then
If Me.[ComboName]<> Me.[ComboName].OldValue Then
If MsgBox("The value was changed, Would you like to undo the
changes?", vbYesNo) = vbYes Then
' Undo the changes
SendKeys "{ESC}"
End If
End If
End If

--
Good Luck
BS"D


Frank Situmorang said:
Hello:

I have an input form using combo, but it could happen the users or other
people hit again the arrow head and choose another choice and the record was
updated wrongly. My question is how can we avoide that people unintentionally
modify the data say " supplier name". I know that there is something to
change in the event property. But I do not really know how to make it. But
again there is a situation that we intentionally need to change the data "
supplier name " because we input it wrongly.

Thank you,

Frank
 
F

Frank Situmorang

Thank you Ofer, it works fatasticly, especially after I modified a bit, that
it should be "no" to meet our needs.

Could you tell me how to make it that No is the default in the question,
rather than Yes?, because people tendency is to click Yes without thinking.

Thanks a lot

Frank

Ofer Cohen said:
In the Combo BeforeUpdate event you can write the code if the data was
changed, if so ask the user if he/she want to save it

If Not IsNull(Me.[ComboName].OldValue) Then
If Me.[ComboName]<> Me.[ComboName].OldValue Then
If MsgBox("The value was changed, Would you like to undo the
changes?", vbYesNo) = vbYes Then
' Undo the changes
SendKeys "{ESC}"
End If
End If
End If

--
Good Luck
BS"D


Frank Situmorang said:
Hello:

I have an input form using combo, but it could happen the users or other
people hit again the arrow head and choose another choice and the record was
updated wrongly. My question is how can we avoide that people unintentionally
modify the data say " supplier name". I know that there is something to
change in the event property. But I do not really know how to make it. But
again there is a situation that we intentionally need to change the data "
supplier name " because we input it wrongly.

Thank you,

Frank
 
O

Ofer Cohen

Change the vbYes to vbNo.
also, if you delete "= vbYes " and then write "=" you'll get the options for
it (Yes or No)


If Not IsNull(Me.[ComboName].OldValue) Then
If Me.[ComboName]<> Me.[ComboName].OldValue Then
If MsgBox("Would you like to save the changes?", vbYesNo) = vbNo
Then
' Undo the changes
SendKeys "{ESC}"
End If
End If
End If

Frank Situmorang said:
Thank you Ofer, it works fatasticly, especially after I modified a bit, that
it should be "no" to meet our needs.

Could you tell me how to make it that No is the default in the question,
rather than Yes?, because people tendency is to click Yes without thinking.

Thanks a lot

Frank

Ofer Cohen said:
In the Combo BeforeUpdate event you can write the code if the data was
changed, if so ask the user if he/she want to save it

If Not IsNull(Me.[ComboName].OldValue) Then
If Me.[ComboName]<> Me.[ComboName].OldValue Then
If MsgBox("The value was changed, Would you like to undo the
changes?", vbYesNo) = vbYes Then
' Undo the changes
SendKeys "{ESC}"
End If
End If
End If

--
Good Luck
BS"D


Frank Situmorang said:
Hello:

I have an input form using combo, but it could happen the users or other
people hit again the arrow head and choose another choice and the record was
updated wrongly. My question is how can we avoide that people unintentionally
modify the data say " supplier name". I know that there is something to
change in the event property. But I do not really know how to make it. But
again there is a situation that we intentionally need to change the data "
supplier name " because we input it wrongly.

Thank you,

Frank
 
K

Klatuu

That may not be sufficient. If you use one of the defaultbutton constants,
you can control the default.

If MsgBox("Would you like to save the changes?", vbYesNo +
vbQuestion + vbDefaultButton2) = vbNo

--
Dave Hargis, Microsoft Access MVP


Ofer Cohen said:
Change the vbYes to vbNo.
also, if you delete "= vbYes " and then write "=" you'll get the options for
it (Yes or No)


If Not IsNull(Me.[ComboName].OldValue) Then
If Me.[ComboName]<> Me.[ComboName].OldValue Then
If MsgBox("Would you like to save the changes?", vbYesNo) = vbNo
Then
' Undo the changes
SendKeys "{ESC}"
End If
End If
End If

Frank Situmorang said:
Thank you Ofer, it works fatasticly, especially after I modified a bit, that
it should be "no" to meet our needs.

Could you tell me how to make it that No is the default in the question,
rather than Yes?, because people tendency is to click Yes without thinking.

Thanks a lot

Frank

Ofer Cohen said:
In the Combo BeforeUpdate event you can write the code if the data was
changed, if so ask the user if he/she want to save it

If Not IsNull(Me.[ComboName].OldValue) Then
If Me.[ComboName]<> Me.[ComboName].OldValue Then
If MsgBox("The value was changed, Would you like to undo the
changes?", vbYesNo) = vbYes Then
' Undo the changes
SendKeys "{ESC}"
End If
End If
End If

--
Good Luck
BS"D


:

Hello:

I have an input form using combo, but it could happen the users or other
people hit again the arrow head and choose another choice and the record was
updated wrongly. My question is how can we avoide that people unintentionally
modify the data say " supplier name". I know that there is something to
change in the event property. But I do not really know how to make it. But
again there is a situation that we intentionally need to change the data "
supplier name " because we input it wrongly.

Thank you,

Frank
 
O

Ofer Cohen

Hi Dave,
I actullay misunderstood the question

Thanks

--
Good Luck
BS"D


Klatuu said:
That may not be sufficient. If you use one of the defaultbutton constants,
you can control the default.

If MsgBox("Would you like to save the changes?", vbYesNo +
vbQuestion + vbDefaultButton2) = vbNo

--
Dave Hargis, Microsoft Access MVP


Ofer Cohen said:
Change the vbYes to vbNo.
also, if you delete "= vbYes " and then write "=" you'll get the options for
it (Yes or No)


If Not IsNull(Me.[ComboName].OldValue) Then
If Me.[ComboName]<> Me.[ComboName].OldValue Then
If MsgBox("Would you like to save the changes?", vbYesNo) = vbNo
Then
' Undo the changes
SendKeys "{ESC}"
End If
End If
End If

Frank Situmorang said:
Thank you Ofer, it works fatasticly, especially after I modified a bit, that
it should be "no" to meet our needs.

Could you tell me how to make it that No is the default in the question,
rather than Yes?, because people tendency is to click Yes without thinking.

Thanks a lot

Frank

:

In the Combo BeforeUpdate event you can write the code if the data was
changed, if so ask the user if he/she want to save it

If Not IsNull(Me.[ComboName].OldValue) Then
If Me.[ComboName]<> Me.[ComboName].OldValue Then
If MsgBox("The value was changed, Would you like to undo the
changes?", vbYesNo) = vbYes Then
' Undo the changes
SendKeys "{ESC}"
End If
End If
End If

--
Good Luck
BS"D


:

Hello:

I have an input form using combo, but it could happen the users or other
people hit again the arrow head and choose another choice and the record was
updated wrongly. My question is how can we avoide that people unintentionally
modify the data say " supplier name". I know that there is something to
change in the event property. But I do not really know how to make it. But
again there is a situation that we intentionally need to change the data "
supplier name " because we input it wrongly.

Thank you,

Frank
 
K

Klatuu

really, wow, I haven't done that in ...hours :)
--
Dave Hargis, Microsoft Access MVP


Ofer Cohen said:
Hi Dave,
I actullay misunderstood the question

Thanks

--
Good Luck
BS"D


Klatuu said:
That may not be sufficient. If you use one of the defaultbutton constants,
you can control the default.

If MsgBox("Would you like to save the changes?", vbYesNo +
vbQuestion + vbDefaultButton2) = vbNo

--
Dave Hargis, Microsoft Access MVP


Ofer Cohen said:
Change the vbYes to vbNo.
also, if you delete "= vbYes " and then write "=" you'll get the options for
it (Yes or No)


If Not IsNull(Me.[ComboName].OldValue) Then
If Me.[ComboName]<> Me.[ComboName].OldValue Then
If MsgBox("Would you like to save the changes?", vbYesNo) = vbNo
Then
' Undo the changes
SendKeys "{ESC}"
End If
End If
End If

Thank you Ofer, it works fatasticly, especially after I modified a bit,
that
it should be "no" to meet our needs.

Could you tell me how to make it that No is the default in the question,
rather than Yes?, because people tendency is to click Yes without
thinking.

Thanks a lot

Frank

:

In the Combo BeforeUpdate event you can write the code if the data was
changed, if so ask the user if he/she want to save it

If Not IsNull(Me.[ComboName].OldValue) Then
If Me.[ComboName]<> Me.[ComboName].OldValue Then
If MsgBox("The value was changed, Would you like to undo the
changes?", vbYesNo) = vbYes Then
' Undo the changes
SendKeys "{ESC}"
End If
End If
End If

--
Good Luck
BS"D


:

Hello:

I have an input form using combo, but it could happen the users or
other
people hit again the arrow head and choose another choice and the
record was
updated wrongly. My question is how can we avoide that people
unintentionally
modify the data say " supplier name". I know that there is something
to
change in the event property. But I do not really know how to make it.
But
again there is a situation that we intentionally need to change the
data "
supplier name " because we input it wrongly.

Thank you,

Frank
 
J

John W. Vinson

If Not IsNull(Me.[ComboName].OldValue) Then
If Me.[ComboName]<> Me.[ComboName].OldValue Then
If MsgBox("Would you like to save the changes?", vbYesNo) = vbNo
Then
' Undo the changes
SendKeys "{ESC}"
End If
End If
End If

Just one minor tweak I'd suggest, Ofer - SendKeys is buggy, unreliable and
unavailable in 2007. Instead of

SendKeys "{ESC}"

you can get the same effect more safely with

Me.[Comboname].Undo


John W. Vinson [MVP]
 
O

Ofer Cohen

I know John,
I tried it with a combo (Bounded) but for some reason it just didn't do it,
it didn't return the ld value.

This is why I changed the approach to the SendKeys, which I know it buggy,
but did the job that the Undo didn't


--
Good Luck
BS"D


John W. Vinson said:
If Not IsNull(Me.[ComboName].OldValue) Then
If Me.[ComboName]<> Me.[ComboName].OldValue Then
If MsgBox("Would you like to save the changes?", vbYesNo) = vbNo
Then
' Undo the changes
SendKeys "{ESC}"
End If
End If
End If

Just one minor tweak I'd suggest, Ofer - SendKeys is buggy, unreliable and
unavailable in 2007. Instead of

SendKeys "{ESC}"

you can get the same effect more safely with

Me.[Comboname].Undo


John W. Vinson [MVP]
 
J

John W. Vinson

I tried it with a combo (Bounded) but for some reason it just didn't do it,
it didn't return the ld value.

Odd! It works fine for me. It should restore the value of the combo to the
value when the user first touched the record (NULL if it's a new record,
previous value if not). I'll do some expermenting.

John W. Vinson [MVP]
 
F

Frank Situmorang

Thanks to all of you who live in advanced countries. All your advices are
beneficial to us who live in a developping country, Indonesia. Ofer's 1st
advice works perfectly for me when I modified it a bit to be: = vbNo as below:
If Not IsNull(Me.[ExpClass].OldValue) Then
If Me.[ExpClass] <> Me.[ExpClass].OldValue Then
If MsgBox("Anda telah merobah!!, apakah sengaja mau merobah?",
vbYesNo) = vbNo Then
' Undo the changes
SendKeys "{ESC}"
End If
End If
End If

Again, Thanks a lot,

Frank
 
F

Frank Situmorang

Ofer,
It works for me, but now the side effect is the invoice no. field which is a
primary key does not function, when I tried to type the same invoice number
for the new record it can accept, while before if the same number it was
rejected as it is a primary key.

Please help how can we solve the problem on this primary key.

On other things, why Winson said it is buggy.

Thanks,

Frank


Ofer Cohen said:
Change the vbYes to vbNo.
also, if you delete "= vbYes " and then write "=" you'll get the options for
it (Yes or No)


If Not IsNull(Me.[ComboName].OldValue) Then
If Me.[ComboName]<> Me.[ComboName].OldValue Then
If MsgBox("Would you like to save the changes?", vbYesNo) = vbNo
Then
' Undo the changes
SendKeys "{ESC}"
End If
End If
End If

Frank Situmorang said:
Thank you Ofer, it works fatasticly, especially after I modified a bit, that
it should be "no" to meet our needs.

Could you tell me how to make it that No is the default in the question,
rather than Yes?, because people tendency is to click Yes without thinking.

Thanks a lot

Frank

Ofer Cohen said:
In the Combo BeforeUpdate event you can write the code if the data was
changed, if so ask the user if he/she want to save it

If Not IsNull(Me.[ComboName].OldValue) Then
If Me.[ComboName]<> Me.[ComboName].OldValue Then
If MsgBox("The value was changed, Would you like to undo the
changes?", vbYesNo) = vbYes Then
' Undo the changes
SendKeys "{ESC}"
End If
End If
End If

--
Good Luck
BS"D


:

Hello:

I have an input form using combo, but it could happen the users or other
people hit again the arrow head and choose another choice and the record was
updated wrongly. My question is how can we avoide that people unintentionally
modify the data say " supplier name". I know that there is something to
change in the event property. But I do not really know how to make it. But
again there is a situation that we intentionally need to change the data "
supplier name " because we input it wrongly.

Thank you,

Frank
 
O

Ofer Cohen

--It works for me, but now the side effect is the invoice no. field which is a
--primary key does not function, when I tried to type the same invoice number
--for the new record it can accept, while before if the same number it was
--rejected as it is a primary key.

---Please help how can we solve the problem on this primary key.
On the beforeUpdate event of the Invoice field, check if that value was
already entered, look at this link for example code

"Preventing Duplicates from being entered"
http://www.databasedev.co.uk/duplicates.html

--On other things, why Winson said it is buggy.
John refred to
SendKeys "{ESC}"
That simulate you pressing the ESC key in the key board to return the old
value, and his right. There is a command that used to return the old value
(Undo)
So, instead of using send keys, you can use
Me.[ComboName].Undo

Before I posted the reply, the undo didn't return the old value (as it
should) and this is why I used the ESC.
You can try using the Undo, it might (and it should) work for you.
 
A

AccessVandal via AccessMonster.com

Hi Frank,

I don’t know what happened to the table. Check the primary key index property
“Yes (No Duplicates)â€.

Here is the solution without the sendkeys. The Me.ExpClass.Undo does not work
and the codes given by Ofer Cohen doe not work in the BeforeUpdate Event.
Instead use the AfterUpdate event in that combo box.

I have included the Me.Dirty just in case you need this. But it will also
undo all changed fields in your form. Remove it if you don’t want to undo
other fields/controls. But remember, the form is still “Dirtyâ€, this means
you got to manually press the “Esc†key else just simply ignore.

If Not IsNull(Me.CusID.OldValue) Then
If Me.ExpClass <> Me.ExpClass.OldValue Then
If MsgBox("You have change!!, Why purposely change?", vbYesNo) = vbYes
Then
' Undo the changes
Me.ExpClass = Me.ExpClass.OldValue
‘use this if there are no other changes in you form
Me.Dirty = False
End If
End If
End If

Note: Forgive me on the loose translation of Indonesian.
Frank Situmorang wrote:
Ofer,
It works for me, but now the side effect is the invoice no. field which is a
primary key does not function, when I tried to type the same invoice number
for the new record it can accept, while before if the same number it was
rejected as it is a primary key.

Please help how can we solve the problem on this primary key.

On other things, why Winson said it is buggy.

Thanks,

Frank
Change the vbYes to vbNo.
also, if you delete "= vbYes " and then write "=" you'll get the options for
[quoted text clipped - 54 lines]
 
F

Frank Situmorang

Hi Vandal,

It seems that you understand Indonesian, where do you live actually?. I am
in Jakarta, Indonesia.

You are right when I chekced the table which is already in the Back End ( in
our server, I see that the Invoice number is no longer primarykey and
duplicate is ok. How this could happen. Is that because I continues upgrading
on my Front End?, and any VBA that can change it?, let say, like " Send Key
"Esc" could change it?, I don't think so, or some body open the table and
change the property?, I do not think there is one who understand about access.

Vandal, also the thing that I do not know yet, how can I make the default in
the Yes/No buttons, I want the No button is the default, because when I make
the one the Ofer proposed in the date field which uses pop up calender we can
not chose No. button, because to pop up calender is double click.

Thanks in advance for your triggering my mind again.

Frank

AccessVandal via AccessMonster.com said:
Hi Frank,

I don’t know what happened to the table. Check the primary key index property
“Yes (No Duplicates)â€.

Here is the solution without the sendkeys. The Me.ExpClass.Undo does not work
and the codes given by Ofer Cohen doe not work in the BeforeUpdate Event.
Instead use the AfterUpdate event in that combo box.

I have included the Me.Dirty just in case you need this. But it will also
undo all changed fields in your form. Remove it if you don’t want to undo
other fields/controls. But remember, the form is still “Dirtyâ€, this means
you got to manually press the “Esc†key else just simply ignore.

If Not IsNull(Me.CusID.OldValue) Then
If Me.ExpClass <> Me.ExpClass.OldValue Then
If MsgBox("You have change!!, Why purposely change?", vbYesNo) = vbYes
Then
' Undo the changes
Me.ExpClass = Me.ExpClass.OldValue
‘use this if there are no other changes in you form
Me.Dirty = False
End If
End If
End If

Note: Forgive me on the loose translation of Indonesian.
Frank Situmorang wrote:
Ofer,
It works for me, but now the side effect is the invoice no. field which is a
primary key does not function, when I tried to type the same invoice number
for the new record it can accept, while before if the same number it was
rejected as it is a primary key.

Please help how can we solve the problem on this primary key.

On other things, why Winson said it is buggy.

Thanks,

Frank
Change the vbYes to vbNo.
also, if you delete "= vbYes " and then write "=" you'll get the options for
[quoted text clipped - 54 lines]
 
A

AccessVandal via AccessMonster.com

Hi Frank,

There was an incident with Forms/Subforms that might cause this problem. For
example, this code from MS http://support.microsoft.com/kb/210236. This code
will only work on a Single Form but if you use it on a MainForm with a
Subform, it will change the Index property of that table. I’m unable to
determine what causes it to change.

Note that I have miss out on “Me.Undoâ€. This will clear all the previous
entry not the “Me.Dirtyâ€.


If you do not want the user the change the data on that combo box, than use
the “vbOKOnlyâ€.
As the “vbOKOnly†is only the default button, the users have only one choice.

Use it on the combo AfterUpdate event.

If Not IsNull(Me.CusID.OldValue) Then
If Me.ExpClass <> Me.ExpClass.OldValue Then
If MsgBox("You have change!!, Why purposely change?", vbOKOnly) = vbOK
Then
' Undo the changes
Me.ExpClass = Me.ExpClass.OldValue
‘use this if there are no other changes in you form
Me.Undo ‘ undo all previous fields
Me.Dirty = False
End If
End If
End If

If Ofer’s code works for you with the send keys, than use that. But remember,
the form is still “Dirty†if the users have also change other fields.
 
Top