REQUERYING FORM

  • Thread starter Thread starter AAron
  • Start date Start date
A

AAron

Hello,

I'm somewhat new to Access, but have developed a runtime
application (data entry form) to put on multiple computers
in my plant. These are there to enter repair information.
I needed my forms on all the computers to update everytime
a record was entered. Hence, I was told to REQUERY with
the ON TIMER event and to save on an event, which I did.
However, when the requery takes place, one of my folks
might be right in the middle of entering data into a new
record, and the requery takes them back to the first
record. First question...is there any better way for the
forms to be updated with new data. Second, if not, when I
requery, can I have it so it leaves me in the record and
field I'm working with? Thanks much,

Aaron
 
Someone may have a better way of doing what you're doing, but there may be
some things that will make the current method work better.

When you requery, wrap the requery command in an IF statement:

If Not (Me.Dirty Or Me.NewRecord) Then
Me.Requery
End If

This will prevent the requery if the form is dirty (i.e. being edited) or if
it is at a new record (whether or not data has been entered yet).

Also, before you requery, save the value of a unique field in the current
record. After the requery, move to that field using the value you saved as
the search criteria. Also, I would probably set the mouse cursor to an
hourglass and echo to false until you are done.

If Not (Me.Dirty Or Me.NewRecord) Then
DoCmd.Hourglass = True
DoCmd.Echo = False
lngRememberID = Me.txtRecordID
Me.Requery
Me.RecordSet.FindFirst "[RecordIDField] = " & lngRememberID
DoCmd.Echo = True
DoCmd.Hourglass = False
If Me.RecordSet.NoMatch Then
Msgbox "The previous record can no longer be found, it may have been
deleted."
End If
End If
 
Hello,

I'm somewhat new to Access, but have developed a runtime
application (data entry form) to put on multiple computers
in my plant. These are there to enter repair information.
I needed my forms on all the computers to update everytime
a record was entered. Hence, I was told to REQUERY with
the ON TIMER event and to save on an event, which I did.
However, when the requery takes place, one of my folks
might be right in the middle of entering data into a new
record, and the requery takes them back to the first
record. First question...is there any better way for the
forms to be updated with new data. Second, if not, when I
requery, can I have it so it leaves me in the record and
field I'm working with? Thanks much,

Aaron,

The db should be split Frontend and Backend.

The FE hold all of the code, forms, reports and queries. The BE hold
only the tables and relationships.

AND, each user should have their own copy of the FE.

Doing that will take care of your problems - and more to come.

- Jim
 
-----Original Message-----


Aaron,

The db should be split Frontend and Backend.

The FE hold all of the code, forms, reports and queries. The BE hold
only the tables and relationships.

AND, each user should have their own copy of the FE.

Doing that will take care of your problems - and more to come.

- Jim


.
Hi Jim,

I have already done that. The runtimes I distribute are
my front ends, and they enter data into my backend, which
I split after creating the form. The problem listed above
is still happening. I have the same runtime form on what
could be 15 machines. I can't seem to get the forms to
update or refresh without doing a requery...
 
I don't really see how splitting the application will solve the OP's
question ...
 
I have already done that. The runtimes I distribute are
my front ends, and they enter data into my backend, which
I split after creating the form. The problem listed above
is still happening. I have the same runtime form on what
could be 15 machines. I can't seem to get the forms to
update or refresh without doing a requery...

Hi Aaron,

Ok, I see what you are doing - sorry I missed that.
How about instead of a timed requery have the timer check the record
count and requery *only* if it has changed.

Set a module level variable "mlngRecCount" (in the Declarations at the
top of the form's module)

Dim mlngRecCount As Long

Initialize this when the form opens.
mlngRecCount = DCount("*","tblMyTable")


In the code for the timer do a DCount and compare it to mlngRecCount.

Dim lngCount As Long
Dim lngPK As Long

lngCount = DCount("*","tblMyTable")

If lngCount <> mlngRecCount And Not Me.Dirty Then
lngPK = Me.myprimarykey
Me.Requery
Me.RecordsetClone.FindFirst "myprimarykey=" & lngPK
Me.BookMark = Me.RecordsetClone.Bookmark
mlngRecCount = lngCount
End If

- Jim
 
You're quite right. I missed that first sentence - got distracted on
this end - as I mentioned to Aaron earlier.

So many folks *do* attempt to run from a single application that I
thought that was what was being done when Aaron mentioned:
However, when the requery takes place, one of my folks
might be right in the middle of entering data into a new
record, and the requery takes them back to the first
record.
My error.

- Jim
 
Back
Top