count records in an unbound subform

S

SUZYQ

I have an unbound datasheet subform on a main form that is used to
capture listing number(s). I enter the "one" information on the main
form and the "many" information in the subform. In other words, one
document may have multiple listing numbers.

How can I count the number of rows that the user enters on the unbound
subform? I need to be able to count the rows and iterate through the
values that are provided.

Thanks,
 
R

Rick B

Why are you saying this is UNBOUND? It sounds to me like you are pulling
info from a table. That makes it bound.
 
S

SUZYQ

No, I'm not pulling from a table. There is no recordsource behind the
main form or the subform.

I'm sorry for not being clearer.

What I forgot to say is that all the fields on the main form and
subform are unbound. Once the user tries to save the record, all the
code runs to validate that all the data is valid and works together.
This is the time when I need to determine how many records are in the
subform. If the data is OK, I then write it to the tables.
 
P

Pieter Wijnen

how about binding to temporary tables - using the Access/Windows login as a
filter?

Pieter
 
S

SUZYQ

I thought about temporary tables too, but wouldn't it make more sense
to make the temp table local in the front end instead of the backend?
I just worry about the bloat to the database and was hoping to capture
it more dynamically.
 
A

Albert D.Kallal

Once the user tries to save the record, all the
code runs to validate that all the data is valid and works together.
This is the time when I need to determine how many records are in the
subform. If the data is OK, I then write it to the tables.

First, if the sub-form is un-bound, then there CAN NOT be any records
to count, can there? I suspect, that in fact your sub-form is abound.

And, to be clear, a un-bound control is a control that does not have the
"control source" set in the properties sheet for that control (in the data
tab) to a field in the forms underlying datasouce.

And, you can also have a un-bound form. A unbound form is simply a form that
is NOT attached to a table. And, this would thus mean the Record Source
setting in the forms properties would be blank.

So, if you got a un-bound sub-form, then there is no way to count the number
of records in that form because un-bound forms don't have records.

Assuming, the above is a miss-understanding, I going to bet that you do in
fact
have a bound sub form. You can get a reocrdcount like:

me.MySubFormControal.Form.Recordsetclone.RecocrdCount

so, for example:
msgbox "records in sub form = " & _
me.MySubFormControal.Form.Recordsetclone.RecocrdCount
 
S

SUZYQ

Thanks Albert!

I must be going about this the wrong way then. You're right, neither
my main form or subform have recordsources.

What I'm trying to do is allow users to enter data in a form, validate
all that data, and then only write it to the tables once I'm happy that
the user has done what they need to. That's why I made the forms
unbound so that I don't get "bad" records in the system.

I went with the main form/subform format so that the user could enter
the unique data about the record on the main form, and then enter the
"many" listing numbers associated with that one main record.

I'm open to ideas about a different way to do this.

Thanks,
 
A

Albert D.Kallal

I went with the main form/subform format so that the user could enter
the unique data about the record on the main form, and then enter the
"many" listing numbers associated with that one main record.

The problem is that you can't have a "many" number of records in a un-bound
form, and especially if this is going to be a continuous form.
I'm open to ideas about a different way to do this.

You need to make temp tables, and put the data in the temp tables. After you
validate, you then move the data from the temp tables to the main table.

(how did you plan to move the data in your existing example?).
 
Top