Peculiar jump in subform

  • Thread starter Thread starter Rolf Rosenquist
  • Start date Start date
R

Rolf Rosenquist

In a subform showing a datasheet I have a combo box to choose an item and a
field for the number of items to choose. When the user has made his choices,
the cursor does not jump to the next, or a new post. Instead it jumps back
to the combo in the same row, so that there has to be two more inputs of
enter before the cursor jumps down.

I have the same type of subform with datasheet in another application and
there it works just as I intended. I have tried to find a differnce between
them, but to no avail. Does anyone know where and how to find it?

/ Rolf
 
If pressing the down arrow takes you to the next field in the same record
and not to the next record below, then the form is in Continous Form view,
not Datasheet view.

It is possible to use code in the form's KeyPress event procedure to move
record when you press the up/down arrows in a continuous form. Post a back
reply to this thread if that is what you need.
 
Allen Browne said:
If pressing the down arrow takes you to the next field in the same record
and not to the next record below, then the form is in Continous Form view,
not Datasheet view.
It is different: Key down on a field without changing value goes down to the
same field on the next record. With enter, it jumps to the first field in
the next record.
But when the value is new or changed, the cursor jumps back in the same
record.
I have checked that the form is in Datasheet mode.

It is possible to use code in the form's KeyPress event procedure to move
record when you press the up/down arrows in a continuous form. Post a back
reply to this thread if that is what you need.
Could be, but I must have it in datasheet mode. Is it the same for enter key
as down arrow?

/ Rolf
 
If the cursor is not moving as expected, then there are most likely events
that are being processed that are interferring.

Are there any events in the control, or in the form?
Does it make any difference if you temporarily insert Exit Sub as the first
line so these events do not run.
 
Yes there is code in the AfterUpdate event that gives value to variables and
so on.
But no, the behavior is the same with Exit Sub as the first statement.

/ Rolf
 
I also tried to jump with code:

Private Sub Antal_AfterUpdate()
AntalIorder = [Antal]
LagerAntal = LagerOchOrder - AntalIorder
sqlText = "UPDATE produkter SET [antal]=" & [LagerAntal] & " WHERE
[ProdID] = " & [OrderSpec.ProdID] & ";"
DoCmd.SetWarnings False
DoCmd.RunSQL sqlText
DoCmd.SetWarnings False

Me.SummaPris = Me.Summa
Me.K_Rabatt = Me.Kundrabatt
' DoCmd.GoToRecord , , acNewRec
' DoCmd.GoToRecord , , acNext
End Sub

Tried also both two last rows one at a time, but they gave an error no.
2105 - Cannot move to this record.
/ Rolf
 
In the AfterUpate event of the control, you are executing an update query
statement. Is this form bound to the "produkter" table?

You are also altering the values of two other controls in the form
(SummaPris and K_Rabatt) in this event.

At this point, the form is dirty (i.e. fields have changed but the changes
are not yet saved). That is probably the reason you cannot move record yet.
You could try saving the record:
Me.Dirty = False

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

Rolf Rosenquist said:
I also tried to jump with code:

Private Sub Antal_AfterUpdate()
AntalIorder = [Antal]
LagerAntal = LagerOchOrder - AntalIorder
sqlText = "UPDATE produkter SET [antal]=" & [LagerAntal] & " WHERE
[ProdID] = " & [OrderSpec.ProdID] & ";"
DoCmd.SetWarnings False
DoCmd.RunSQL sqlText
DoCmd.SetWarnings False

Me.SummaPris = Me.Summa
Me.K_Rabatt = Me.Kundrabatt
' DoCmd.GoToRecord , , acNewRec
' DoCmd.GoToRecord , , acNext
End Sub

Tried also both two last rows one at a time, but they gave an error no.
2105 - Cannot move to this record.
/ Rolf



Allen Browne said:
If the cursor is not moving as expected, then there are most likely
events
that are being processed that are interferring.

Are there any events in the control, or in the form?
Does it make any difference if you temporarily insert Exit Sub as the first
line so these events do not run.
 
Allen Browne said:
In the AfterUpate event of the control, you are executing an update query
statement. Is this form bound to the "produkter" table?
Yes, that is rght

You are also altering the values of two other controls in the form
(SummaPris and K_Rabatt) in this event.

At this point, the form is dirty (i.e. fields have changed but the changes
are not yet saved). That is probably the reason you cannot move record yet.
You could try saving the record:
Me.Dirty = False
Me.Dirty=False did not change anything. I did not understand if you meant
that for the form or any of the controls, so I tested all of them.


I found a difference to the working application I mentioned. There is a
control in the main form for a calculated total sum in the footer of the
subform. I erased that also for a try, but unfortunately, that did not help
either.

/ Rolf


--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

Rolf Rosenquist said:
I also tried to jump with code:

Private Sub Antal_AfterUpdate()
AntalIorder = [Antal]
LagerAntal = LagerOchOrder - AntalIorder
sqlText = "UPDATE produkter SET [antal]=" & [LagerAntal] & " WHERE
[ProdID] = " & [OrderSpec.ProdID] & ";"
DoCmd.SetWarnings False
DoCmd.RunSQL sqlText
DoCmd.SetWarnings False

Me.SummaPris = Me.Summa
Me.K_Rabatt = Me.Kundrabatt
' DoCmd.GoToRecord , , acNewRec
' DoCmd.GoToRecord , , acNext
End Sub

Tried also both two last rows one at a time, but they gave an error no.
2105 - Cannot move to this record.
/ Rolf



Allen Browne said:
If the cursor is not moving as expected, then there are most likely
events
that are being processed that are interferring.

Are there any events in the control, or in the form?
Does it make any difference if you temporarily insert Exit Sub as the first
line so these events do not run.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.


"Allen Browne" <[email protected]> skrev i meddelandet
If pressing the down arrow takes you to the next field in the same record
and not to the next record below, then the form is in Continous Form
view,
not Datasheet view.

It is different: Key down on a field without changing value goes down
to
the
same field on the next record. With enter, it jumps to the first
field
in
the next record.
But when the value is new or changed, the cursor jumps back in the same
record.
I have checked that the form is in Datasheet mode.


It is possible to use code in the form's KeyPress event procedure to move
record when you press the up/down arrows in a continuous form. Post a
back
reply to this thread if that is what you need.

Could be, but I must have it in datasheet mode. Is it the same for
enter
key
as down arrow?

/ Rolf


In a subform showing a datasheet I have a combo box to choose an
item
and
a
field for the number of items to choose. When the user has made his
choices,
the cursor does not jump to the next, or a new post. Instead it
jumps
back
to the combo in the same row, so that there has to be two more
inputs
of
enter before the cursor jumps down.

I have the same type of subform with datasheet in another
application
and
there it works just as I intended. I have tried to find a differnce
between
them, but to no avail. Does anyone know where and how to find it?
 
I got it working by two SendKeys"{Enter}" after the other code in the
AfterUpdate to the Antal control.
I know this is not the right method, as the other application works without
it. Hope there are no problems with other functions.

If you do come to think of another better solution, I would be greatful to
hear about it and try.
Regards
/ Rolf


Rolf Rosenquist said:
Allen Browne said:
In the AfterUpate event of the control, you are executing an update query
statement. Is this form bound to the "produkter" table?
Yes, that is rght

You are also altering the values of two other controls in the form
(SummaPris and K_Rabatt) in this event.

At this point, the form is dirty (i.e. fields have changed but the changes
are not yet saved). That is probably the reason you cannot move record yet.
You could try saving the record:
Me.Dirty = False
Me.Dirty=False did not change anything. I did not understand if you meant
that for the form or any of the controls, so I tested all of them.


I found a difference to the working application I mentioned. There is a
control in the main form for a calculated total sum in the footer of the
subform. I erased that also for a try, but unfortunately, that did not help
either.

/ Rolf


--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

Rolf Rosenquist said:
I also tried to jump with code:

Private Sub Antal_AfterUpdate()
AntalIorder = [Antal]
LagerAntal = LagerOchOrder - AntalIorder
sqlText = "UPDATE produkter SET [antal]=" & [LagerAntal] & " WHERE
[ProdID] = " & [OrderSpec.ProdID] & ";"
DoCmd.SetWarnings False
DoCmd.RunSQL sqlText
DoCmd.SetWarnings False

Me.SummaPris = Me.Summa
Me.K_Rabatt = Me.Kundrabatt
' DoCmd.GoToRecord , , acNewRec
' DoCmd.GoToRecord , , acNext
End Sub

Tried also both two last rows one at a time, but they gave an error no.
2105 - Cannot move to this record.
/ Rolf



"Allen Browne" <[email protected]> skrev i meddelandet
If the cursor is not moving as expected, then there are most likely
events
that are being processed that are interferring.

Are there any events in the control, or in the form?
Does it make any difference if you temporarily insert Exit Sub as the
first
line so these events do not run.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.


"Allen Browne" <[email protected]> skrev i meddelandet
If pressing the down arrow takes you to the next field in the same
record
and not to the next record below, then the form is in Continous Form
view,
not Datasheet view.

It is different: Key down on a field without changing value goes down
to
the
same field on the next record. With enter, it jumps to the first field
in
the next record.
But when the value is new or changed, the cursor jumps back in the same
record.
I have checked that the form is in Datasheet mode.


It is possible to use code in the form's KeyPress event procedure to
move
record when you press the up/down arrows in a continuous form.
Post
 
Rolf Rosenquist said:
Yes, that is rght

The thing that bothers me is that while the form is dirty, you execute an
update statement and change the SAME table, presumably the same record.

When you go to save the record, it should then give you a write-conflict
dialog, along the lines of:
"You or someone else changed the same record.
Do you want to:
- drop your changes;
- overwrite the changes;
- copy to clipboard."
 
Yes, you are right. Earlier I got such a message and was unable to do the
Update statement. But your tip to run a DoCmd.SetWarnings =False before
and then =True afterwards did help.

/ Rolf
 
Back
Top