473,762 Members | 8,011 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

ADP bound form - force record save, recordsetclone not populating after requery

Br
First issue:

When using ADPs you no longer have the ability to issue a me.refresh to
save the current record on a form (the me.refresh does a requery in an
ADP).

We usually do this before calling up another form or report that uses
some of the same data.

We came up with a work around that saves the current record's ID, does a
requery, then uses a recordsetclone to search for the ID and then set
the form's bookmark to the recordset clone's. This is the same method we
use for our search functions on our forms (without the requery
obviously).

This doesn't always work because of the second issue below.

How can you save the current record on a bound form in an ADP?

Second issue:

The above searching method seemed to work until we encountered larger
recordsets. It seems that Access doesn't get all the data immediately
after you requery so the recordsetclone only contains a small subset of
records... thus the search routine fails to find the record for higher
ID values. If you trace through the code a line at a time it works fine.
Adding a pause loop in the code doesn't work (and is a bad practice
IMO).

How can you make sure a recordsetclone contains all the records after a
requery?

For now I've had to implement a terrible practice... in code move the
form to the next record and then move back which causes the record to be
saved.

Using A2000, SQL2000
--
regards,

Bradley

A Christian Response
http://www.pastornet.net.au/response
Nov 25 '05
22 5051
Br
Lyle Fairfield wrote:
I'm still not clear about the sequence of your calls. Do you set rs to
nothing before you try to use RecordSetClone? I think this is unwise.
I am strongly of the opinion that one never has to set an ADO
recordset to nothing; others disagree, but I have not done this in
(at least) millions of code calls without any problem whatever.
ADO objects are not DAO objects. One should not treat them as one
treats DAO objects. If they were identical with DAO objects then there
would be no point in using them.
The main form has a button that calls up a second form.

Because of the limitation in A2000/SQL2000 you can only edit one of the
tables in a view. To get around this a second form is opened to edit the
details of the second table. (I didn't design the system but am now
maintaining it - in another version the developer has made the main form
unbound and calls up two secondary forms to edit the detail to get
around some of the issues).

Before the second form is opened some code is run to force the current
record to save.

When the form is closed we need to requery the first form. This is where
my code that does a requery and then moves back to the record we were on
is called.

This all works fine now and with the new code we get around the problem
of opening a recordsetclone and only getting the first 50 or so records.

However, on the main form there are some search routines (select a name
from a list returning the person's ID). This is where the recordsetclone
code is used to move to the searched record.

This code works usually, but if you try and run it after the "refresh"
code then I get an "ActiveX cannot create object" error.

Requery and move back to record code:
Function RefreshForm(myF orm As Form, myField As String)
' sample call : RefreshForm Me, "EmployeeID "
On Error GoTo RefreshForm_err
Dim rs As ADODB.Recordset
Dim myValue As Long
Dim myUniqueTable As String
myValue = myForm.Controls (myField).Value
myUniqueTable = myForm.UniqueTa ble
DoCmd.RunComman d acCmdSelectReco rd
DoCmd.RunComman d acCmdSaveRecord
Set rs = New ADODB.Recordset
With rs
.ActiveConnecti on = CurrentProject. Connection
.CursorLocation = adUseClient
.CursorType = adOpenKeyset
.LockType = adLockBatchOpti mistic
.Source = myForm.RecordSo urce
.Open
End With
rs.Find myField & " = " & myValue
If rs.EOF Then rs.MoveFirst
Set myForm.Recordse t = rs
Set rs = Nothing
myForm.UniqueTa ble = myUniqueTable
RefreshForm_exi t:
Set rs = Nothing
Exit Function
RefreshForm_err :
MsgBox "Could not move to record." & vbCrLf & Err.Description ,
vbCritical +
vbOKOnly, "Error in RefreshForm()"
Resume RefreshForm_exi t
End Function
Search code:
Private Sub reposition(ByVa l findcode As Long)

Dim CRITERIA As String
Dim MYRS As ADODB.Recordset

If IsNull(findcode ) Then
MsgBox "YOU HAVE NOT MADE A SELECTION"
Exit Sub
End If

'Error occurs on this line. "AciveX component can't create object"
Set MYRS = Me.RecordsetClo ne

CRITERIA = "[Personnel_No]=" & findcode
MYRS.Find CRITERIA
If MYRS.EOF Then
MsgBox "COULD NOT FIND THE EMPLOYEE: " & findcode
Else
Me.Bookmark = MYRS.Bookmark
End If
Set MYRS = Nothing

End Sub

--
regards,

Bradley

A Christian Response
http://www.pastornet.net.au/response
Nov 27 '05 #21
Br
RoyVidar wrote:
Br@dley wrote in message
<t_************ ****@news-server.bigpond. net.au> :
Lyle Fairfield wrote:
I don't have any problem with:
With Me.RecordsetClo ne
.Find "Amount > 1000"
MsgBox .Collect(0)
End With

Perhaps, you should post your updated code?


I thought I did?

Function RefreshForm(myF orm As Form, myField As String)
' sample call : RefreshForm Me, "EmployeeID "
On Error GoTo RefreshForm_err
Dim rs As ADODB.Recordset
Dim myValue As Long
Dim myUniqueTable As String
myValue = myForm.Controls (myField).Value
myUniqueTable = myForm.UniqueTa ble
DoCmd.RunComman d acCmdSelectReco rd
DoCmd.RunComman d acCmdSaveRecord
Set rs = New ADODB.Recordset
With rs
.ActiveConnecti on = CurrentProject. Connection
.CursorLocation = adUseClient
.CursorType = adOpenKeyset
.LockType = adLockBatchOpti mistic
.Source = myForm.RecordSo urce
.Open
End With
rs.Find myField & " = " & myValue
If rs.EOF Then rs.MoveFirst
Set myForm.Recordse t = rs
Set rs = Nothing
myForm.UniqueTa ble = myUniqueTable
RefreshForm_exi t:
Set rs = Nothing
Exit Function
RefreshForm_err :
MsgBox "Could not move to record." & vbCrLf & Err.Description ,
vbCritical + vbOKOnly, "Error in RefreshForm()"
Resume RefreshForm_exi t
End Function
The code on the form that does the search is (I didn't write it...).
It works before the above code is run.

Private Sub reposition(ByVa l findcode As Long)

Dim CRITERIA As String
Dim MYRS As ADODB.Recordset

If IsNull(findcode ) Then
MsgBox "YOU HAVE NOT MADE A SELECTION"
Exit Sub
End If

'Error occurs on this line. "AciveX component can't create object"
Set MYRS = Me.RecordsetClo ne

CRITERIA = "[Personnel_No]=" & findcode
MYRS.Find CRITERIA
If MYRS.EOF Then
MsgBox "COULD NOT FIND THE EMPLOYEE: " & findcode
Else
Me.Bookmark = MYRS.Bookmark
End If
Set MYRS = Nothing

End Sub


There are a lot of things I do not understand
with this, so I hope you'll excuse me if some
of this is only a shot in the dark

1 - I seem to recall some anomalities whith
recordsetclone on ADO form recordsets in the
2000 version - could you try just using the
.clone method of the form recordset in
stead, and see if that changes anything?

Set MYRS = Me.Recordset.Cl one

in stead of

Set MYRS = Me.RecordsetClo ne


It seems to have worked! Thanks champ.
<>

--
regards,

Bradley

A Christian Response
http://www.pastornet.net.au/response
Nov 27 '05 #22
"Br@dley" <br**@usenet.or g> wrote in news:V5iif.5225 $ea6.362@news-
server.bigpond. net.au:
Before the second form is opened some code is run to force the current
record to save.

When the form is closed we need to requery the first form. This is where
my code that does a requery and then moves back to the record we were on
is called.


Threads like this remind me that I should just shut up when I'm puzzled
about problems that appear here.
It seems that my way of working is not so similar to that of many others.
For instance
1. the notion of editing (or trying to edit) two tables from one form fills
me with fear;
2. when I get to the point where some code dealing with user interaction
(not calculating code) is involved, long or error prone, I delete the code
and start over; this is based on my strong belief that the Access GUI is
and should be kept simple; when a procedure in a form's module exceeds ten
lines it's suspect;
3. I've never used a VIEW as the recordsource for a form;
4. I use the latest versions of whatever technologies are available to me.

--
Lyle Fairfield
Nov 27 '05 #23

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

19
4107
by: James Fortune | last post by:
I have a lot of respect for David Fenton and Allen Browne, but I don't understand why people who know how to write code to completely replace a front end do not write something that will automate the code that implements managing unbound controls on forms given the superior performance of unbound controls in a client/server environment. I can easily understand a newbie using bound controls or someone with a tight deadline. I guess I need...
14
10143
by: Abhi | last post by:
FYI: This message is for the benefit of MS Access Community. I found that this prblem has been encounterd by many but there is hardly any place where a complete solution is posted. So I thought I should give back to the community by posting our findings. Thanks you all for all your help till now by posting problems and their solutions. ~Abhijit
9
3053
by: Paradigm | last post by:
I am using an Access2K front end to a MYSQL database. If I enter a new record in a continuous form the record appears as #deleted as soon as I move to a different record in the form until I requery the form. After the requery the records are in different order to the order that they may be entered in. The record does not seem to be assigned an ID (autonumber ID field) until after it is requeried. My problem is that after requerying the...
8
12105
by: Zlatko Matić | last post by:
There is a form (single form) and a combobox. I want that current record of the form is adjusted according to selected value in the combobox. Cuurrent record should be the same as the value in the combobox. What is the solution? Thank you in advance.
3
3121
by: Susan Bricker | last post by:
I might not have phrased the question correctly in the Subject of this post. Please read the entire explanation. I have a form with a command button (Add New Person). This button opens up another form (frmPeople) with a NewRecord (blank fields). The frmPeople form has a command button to save the record. I call this scenario ADD Mode. When the record is saved we stay in ADD Mode and get another NewRecord. This form (frmPeople)...
6
8533
by: Henry Stockbridge | last post by:
Hi, I have a popup that is used to update the records on an open form. I cannot get form to refresh with the new values. Any help you can lend would be appreciated. Here is the code for the popup form: '----------------------------------------------- Sub AddRep_Click() Dim db As Database
3
2105
by: Kaur | last post by:
Hi, I would appriceate any help to correct the code error that I am getting for the onclick event of a cmd button. I have two forms. Main Form "frmQuestion" and form 2 "SfrmQuestion". FrmQuestion shows the details about Question and by clicking on one for the cmd button on this form opens up SfrmQuestions that lets me add new questions. The frmQuestion Form remains opened at the backend. My problem is when I save the question in...
1
1932
by: Jimmy | last post by:
There is a command button on the form I'm working on. The form displays one record. The command button creates a new record by copying selected data from the current record: Dim dbs As Database Dim rst As Recordset Set dbs = CurrentDb Set rst = dbs.OpenRecordset("tblProjects", dbOpenDynaset)
2
2638
by: Fa | last post by:
Hi, I'm using this code to pass "codice cliente" values from a form1 to form2. Private Sub Form_Open(Cancel As Integer) Me.RecordsetClone.FindFirst "=" & Forms! ! If Me.RecordsetClone.NoMatch Then Me.RecordsetClone.AddNew Me.RecordsetClone! = Forms!
0
9554
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10137
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9989
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9812
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8814
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5268
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5405
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3914
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3510
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.