problem populating continious form with vb6

S

scoebidoo

Hi

I try to populate a unbound form with unbound textboxes with records from a
table.
What I get is a form filled with textboxes as much as records in the table
and each textbox is filled with the value of the first record.

How can I display the value of each record in the form?

BTW: My form is a continuous form.

My code:
....
strsql = "Select * from Table1"
Set rst = dbs.OpenRecordset(strsql, dbOpenDynaset)
Set MyForm.Recordset=rst
MyForm!Textbox1.Value=rst![Field1]
....
 
T

Tom van Stiphout

On Tue, 11 May 2010 06:22:01 -0700, scoebidoo

Unless you go to extremes, working with a ContinuousForm requires that
you bind the controls to the data. Do not use unbound.
Binding is done by first setting the form's RecordSource property, and
then each control's ControlSource property.

-Tom.
Microsoft Access MVP
 
T

Tom van Stiphout

On Tue, 11 May 2010 23:15:11 GMT, "mie via AccessMonster.com"

Just curious: what benefit does your code have over mine (setting
RecordSource and ControlSource)?

-Tom.
Microsoft Access MVP

In form design view do not set 'Record Source'.
Then for each textbox, set 'Control Source' with fields you need to display .


and your code should be:

strsql = "Select * from Table1"
Set rst = dbs.OpenRecordset(strsql, dbOpenDynaset)
Set MyForm.Recordset=rst

Hi

I try to populate a unbound form with unbound textboxes with records from a
table.
What I get is a form filled with textboxes as much as records in the table
and each textbox is filled with the value of the first record.

How can I display the value of each record in the form?

BTW: My form is a continuous form.

My code:
...
strsql = "Select * from Table1"
Set rst = dbs.OpenRecordset(strsql, dbOpenDynaset)
Set MyForm.Recordset=rst
MyForm!Textbox1.Value=rst![Field1]
...
 
S

scoebidoo

Mie and Tom

Thank you for your quick and effective reactions!
My problem is solved with Tom's answer.

Have a nice day!

mie via AccessMonster.com said:
Just to answer his question..

"each textbox is filled with the value of the first record".

..and thats how i did.

/Pardon for my lack of writing skill.
Just curious: what benefit does your code have over mine (setting
RecordSource and ControlSource)?

-Tom.
Microsoft Access MVP
In form design view do not set 'Record Source'.
Then for each textbox, set 'Control Source' with fields you need to display .
[quoted text clipped - 23 lines]
MyForm!Textbox1.Value=rst![Field1]
...

--
Message posted via AccessMonster.com


.
 

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

Top