updating a display without calling refresh?

G

Guest

I have a form with several subforms. When the user types new information into
the subforms, a calculation is run and the result stored in the "outer"
form's record in the database.

Normally you'd call me.form.refresh to resync the display with the
underlying recordset. But if you do, the entire form state is torn down and
recreated, and in the process the cursor focus changes. This makes it
basically impossible to simply tab through a set of fields and change the
values, because the cursor keeps hoping around the screen

If I don't call refresh, then an edits on the main form causes a "someone
had edited this record" error. That's entirely true, but besides the point, I
don't care!

So is there some way to say "ignore these changes", or some other way to
avoid doing the refresh?

Maury
 
G

Guest

Hi Maury

I don't understnad what your form looks like so I can't understand fully.

Is there some reason why you can't refresh and setfocus in the same event.
Or just requery and return to the same record and set focus

Dim SomeStuffW As Long
SomeStuffW = Me.ID
Me.Requery
Me.RecordsetClone.FindFirst "ID = " & SomeStuffW
If Not Me.RecordsetClone.NoMatch Then
Me.Bookmark = Me.RecordsetClone.Bookmark
End If
Me.Something.SetFocus somewhere


Just an idea ??
 
A

Albert D. Kallal

Maury Markowitz said:
Normally you'd call me.form.refresh to resync the display with the
underlying recordset. But if you do, the entire form state is torn down
and
recreated, and in the process the cursor focus changes.

The above does not sound right? are you talking about a forms requery, or
refresh?


me.Refresh

The above does NOT normally change the cursor focus. However, refresh does
case a disk write of the form, and you might not want that....

You might be able to use a repaint, but your cursor should not move when you
execute the refresh, the exception being some on-current code (which you
might want to change).
 
G

Guest

Wayne-I-M said:
I don't understnad what your form looks like so I can't understand fully.

My database has "orders" that consist of one or more "items".

There is a series of fields along the main form, "quantity", "price", and a
calculated field, "total". These are fields in the "orders" table that
represent totals.

The data for these fields normally comes from a sum query on the "items"
table. With every change in the subform, the query is run and the fields in
the main form are updated.

If and only if there is one "item" in the order, then entering data into the
fields on the main form is also allowed. That's because 90% of orders only
have one item, and the users don't want to have to use the subform. In this
case, when the user enters data into these fields, an event handler copies
the numbers down into the single "items" table. The rest of the query and
update occurs as if the user typed directly into the subform.

And that's the problem. After the query runs the main form's numbers get
updated in the background by the query.

You can't know where to put the focus. Consider the case of a user tabbing
out of a field, vs. shift-tabbing, or clicking in another field.

Maury
 
G

Guest

Albert D. Kallal said:
The above does not sound right? are you talking about a forms requery, or
refresh?
Refresh.

The above does NOT normally change the cursor focus.

It definitely is in my case. I am using a tabview, maybe this has something
to do with it?

Maury
 
G

Guest

I think I have a solution.

The problem occurs when the query updates the underlying tables without the
form being aware of the changes. I changed the code so that the changes to
the main table, the results of the query, are "poked" into the form fields
instead of being updated directly in the underlying table. This way the form
is put in control of saving the data, which avoids the problem.

Fingers crossed...

Maury
 

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