Re: ADO Form bind



"Gsurfdude" <Gsurfdude@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message news:A9768A09-1D71-4323-993A-D71C639714BB@xxxxxxxxxxxxxxxx
Thanks. Yeah, I know to name the control to something meaningful. Now,
setting the control source to County makes the text not updateable that I
need. When you try to enter something, the message at the bottom of Access
displays "This record set is not updateable"

"Chris" wrote:

Delete the line me.text0 = rs!County from your code. Open your form in design
view and set the control source of text0 to County. Then when you set the
recordset in code, it should display as you expect. FWIW, it is helpful to
give a meaningful name to your control, e.g. txtCountyCode instead of text0.

HTH,
Chris

"Gsurfdude" wrote:

> Hello,
>
> I have a form that is set to Continuous and in the Form_Open event I > have
> the code which "binds it"
> Set cn = CurrentProject.AccessConnection
> Set rs = New ADODB.Recordset
> With rs
> Set .ActiveConnection = cn
> .Source = "SELECT * " & _
> "FROM FIELD_COLLECT_ALL WHERE
> FIELD_COLLECT_ALL.Status_user_id='Test';"
>
> .LockType = adLockOptimistic
> .CursorType = adOpenKeyset
> .Open
> End With
> Set Me.Recordset = rs
> me.text0 = rs!County
> Set rs = Nothing
> Set cn = Nothing
>


If you're using Access 2000, I don't believe you can bind an updatable form to an ADO recordset using the Jet provider. If you're using Access 2002 or later, you should be able to, according to this KB article:


http://support.microsoft.com/kb/281998/
How to bind Microsoft Access forms to ADO recordsets

However, that article states that you must also specify a server-side cursor:

.CursorLocation = adUseServer

And "the recordset must contain one or more fields that are uniquely indexed, such as a table's primary key."

I'm curious as to why you are going to all this trouble, though. If you want to bind a form dynamically, why not just set the form's RecordSource property to the desired query? For example, all of your code above could be replaced by:

Me.RecordSource = _
"SELECT * FROM FIELD_COLLECT_ALL " & _
"WHERE Status_user_id='Test';"


--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)

.



Relevant Pages

  • RE: Question 2, splitting and numbering
    ... When you open a recordset using these two lines (already in the code I ... How do I program the code to first Sort by County, ... Dim vcountyHold As String ... Dim vcounter As Integer ...
    (microsoft.public.access.formscoding)
  • Re: Populating labels with code
    ... >I have a form with a number of option groups and there ... >combo box the control source for the option group and text ... You can then open a recordset to retrieve the frame number, ... control source and label caption for the specified call ...
    (microsoft.public.access.formscoding)
  • DataReport in Visual Basic 6
    ... I would like to know if we can bind the same DataReport (Visual Basic ... Qr1 =" Select EMP_ID, FirstName, LastName from Pers where Function ... I just want to know if we can bind two different RecordSet to the Same ...
    (microsoft.public.vb.crystal)
  • DataReport in Visual Basic 6
    ... I would like to know if we can bind the same DataReport (Visual Basic ... Qr1 =" Select EMP_ID, FirstName, LastName from Pers where Function ... I just want to know if we can bind two different RecordSet to the Same ...
    (microsoft.public.vb.general.discussion)
  • DataReport in Visual Basic 6
    ... I would like to know if we can bind the same DataReport (Visual Basic ... Qr1 =" Select EMP_ID, FirstName, LastName from Pers where Function ... I just want to know if we can bind two different RecordSet to the Same ...
    (comp.lang.basic.visual.misc)