unbound form

P

Patrick Jox

As far as I found out in the documentation it is possible to use unbound
forms. But I am having big trouble doing this.

What I do.

I have a subform (sfrFECNAME) designed as an endless form with one lable in
the form header and one textbox in the form details section. The form is not
bound RecourdSource is empty and the textbox control source is set to CNAME.

Then I create a new recordset that is filled manually

Dim rst As ADODB.Recordset
Set rst = New ADODB.Recordset

rst.Fields.Append "CNAME", adBSTR
rst.Open

rst.AddNew
rst!CNAME = "Hallo"
rst.Update

rst.AddNew
rst!CNAME = "Klaus"
rst.Update

Set Me.sfrFECNAME.Form.Recordset = rst

My form is used in a Form and in this form the code above is executed. Good
so far. When the form opens I see the records as added. Now the problems
start.
I can not add a new record. The i tab on the keyboard but nothingis
diaplayed.
I can change the existing entries. But when I click ENTER there is a
problem. Every entry changes to ?Name

What am I doing wrong.

Thanks for every hint!
Regards, Patrick
 
R

Rob Oldfield

Personally I can't get your example to work. But, the big question is...
why bother? It's going to be a great deal easier just to write your values
into a table.
 
P

Patrick Jox

OK, I tried to use this with a table.

My problem is that I can not access the table (recordset) from code.

I added a table tblCNAME with to fields ID (text, 50) and CNAME(text, 255).
The table exists and i added two rows. Now when I try to access the table
from code

set rst = CurrentDb.Recordsets("tblCNAME")

I get an error "element not found in this collection". When I check the
CurrentDb.Recordsets.Count property I see that the collection contains no
items

When I walk through the tabledefs I can see my table.

What is wrong here?

Regards
Patrick
 
R

Rob Oldfield

It would be set rst=currentdb.openrecordset("tblCNAME")

....but why bother with recordsets when you can just do...

me.sfctlName.form.recordsource="TableOrQueryName"
 
P

Patrick Jox

Hi Rob,
This is because this is a temporary table and I have to delete and add
entries on the fly.

OpenRecordset is what I was looking for.

Thanks a lot
Patrick
 

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