Re: ADO Form bind
- From: "Dirk Goldgar" <dg@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Tue, 1 Apr 2008 10:41:01 -0400
"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)
.
- Follow-Ups:
- Re: ADO Form bind
- From: Gsurfdude
- Re: ADO Form bind
- References:
- ADO Form bind
- From: Gsurfdude
- RE: ADO Form bind
- From: Chris
- RE: ADO Form bind
- From: Gsurfdude
- ADO Form bind
- Prev by Date: Re: print from form
- Next by Date: Re: Specify date criteria for subform data
- Previous by thread: RE: ADO Form bind
- Next by thread: Re: ADO Form bind
- Index(es):
Relevant Pages
|