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
 
M

mie via AccessMonster.com

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]
...
 
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]
...
 
M

mie via AccessMonster.com

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]
...
 
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]
...

--



.
 
L

Linq Adams via AccessMonster.com

In point of fact, as Tom intimated, Unbound forms do not contain multiple
records and hence Continuous and Datasheet View forms cannot be used .

Also, mie, you cannot set the value of a textbox using a Select query in
Access VBA. You'd have to use the DLookup function, which is inefficient, and
to be frank, an absurd way to try and populate an entire record!
 
M

mie via AccessMonster.com

Are you sure? I used that method for ADO recordset since my backend is MySQL
(no linked table).
records and hence Continuous and Datasheet View forms cannot be used .
---I'll take that as a joke..:)
to be frank, an absurd way to try and populate an entire record!
---I recommend you try it..
 

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