recordsetclone does not update form display

G

Guest

I am using the following code to move a bound form to a new record:

Property Let CompanyID(id As Long)

Me.RecordsetClone.FindFirst "co_id = " & CStr(id)

If (Me.RecordsetClone.NoMatch) Then
msgbox "Look-up failed at fCompanyAddEdit LET KeyValue # " & CStr(id)
Else
Me.Bookmark = Me.RecordsetClone.Bookmark
End If

End Property

If I display this form and a company list side-by-side on the screen, and
click on a company on the company list, and the following code executes:
Form_fCompanyAddEdit.CompanyID = Me.txtCoID

then the company edit form fCompanyAddEdit moves to the requested record and
the company information is displayed in the form.

However, when these forms are each subforms of another form, the company
editing form does not display updated company information when a new company
is clicked on in the company list.

When I step through the code in debug mode, the code "Me.Bookmark =
Me.RecordsetClone.Bookmark" executes, but the new company is not displayed on
the form! A few minutes ago when I added additional code to track values, it
worked and the new company infomation displayed on the form. So I took out
the extra code, and it stopped working again. The I put the extra code back,
but it will not work again!!!

What would stop a record from displaying when Me.Bookmark =
Me.RecordsetClone.Bookmark appears to execute properly?

Thanks.
 
D

Dirk Goldgar

In
Fredrated said:
I am using the following code to move a bound form to a new record:

Property Let CompanyID(id As Long)

Me.RecordsetClone.FindFirst "co_id = " & CStr(id)

If (Me.RecordsetClone.NoMatch) Then
msgbox "Look-up failed at fCompanyAddEdit LET KeyValue # " &
CStr(id) Else
Me.Bookmark = Me.RecordsetClone.Bookmark
End If

End Property

If I display this form and a company list side-by-side on the screen,
and click on a company on the company list, and the following code
executes: Form_fCompanyAddEdit.CompanyID = Me.txtCoID

then the company edit form fCompanyAddEdit moves to the requested
record and the company information is displayed in the form.

However, when these forms are each subforms of another form, the
company editing form does not display updated company information
when a new company is clicked on in the company list.

When I step through the code in debug mode, the code "Me.Bookmark =
Me.RecordsetClone.Bookmark" executes, but the new company is not
displayed on the form! A few minutes ago when I added additional
code to track values, it worked and the new company infomation
displayed on the form. So I took out the extra code, and it stopped
working again. The I put the extra code back, but it will not work
again!!!

What would stop a record from displaying when Me.Bookmark =
Me.RecordsetClone.Bookmark appears to execute properly?

I'm not sure what's going on, but try it without using the class module
notation to refer to the form. Instead, use a reference through the
main form and the subform control on the main form. For example, if the
company list is a subform of a main form, and fCompanyAddEdit is being
displayed in another subform of that main form, in a subform control
that is also *named* "fCompanyAddEdit", then call it like this:

Me.Parent!fCompanyAddEdit.Form.CompanyID = Me.txtCoID

Note that the name of the subform control may not be the same as the
form object it's displaying; if it isn't, use the name of the subform
control in the above line, instead of "fCompanyAddEdit".

I'd also recommend simplifying your Property Let procedure, while at the
same time ensuring that it is using the same instance of the
recordsetclone throughout, by modifying it like this:

'----- start of revised code -----
Property Let CompanyID(id As Long)

With Me.RecordsetClone

.FindFirst "co_id = " & CStr(id)

If (.NoMatch) Then
MsgBox _
"Look-up failed at fCompanyAddEdit LET KeyValue # " & _
CStr(id)
Else
Me.Bookmark = .Bookmark
End If

End With

End Property
'----- end of revised code -----

There are some versions of Access that get a different recordsetclone
each time you use the RecordsetClone property.

I don't know for sure that these changes will solve your problem, but
give them a try.
 
G

George Nicholson

What would stop a record from displaying when Me.Bookmark =
Me.RecordsetClone.Bookmark appears to execute properly?

It doesn't work as a subform but does when it isn't? As a subform, is it
linked to its Parent by Child/Master links? That could easily prevent any
subform movement unless you change which record is Current on the Parent (or
remove the links)

HTH,
 

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

Similar Threads


Top