Identifying if 1st record in subform

  • Thread starter Thread starter Kelly York
  • Start date Start date
K

Kelly York

I am building a coordination subform so we can
track where a report is.

Before it build a new record I need it to look
at the previous record and make sure the
previous record has been completely filled in.
If not it will not let a new record be added.

I can't just make all the field required for
a record to be saved because initially
someone will only fill in part of the fields.
IN
RCVD BY
RCVD OFF
When they get ready to send out the report
they will finish filling in the rest of the
fields.
OUT
SENT OFF

We don't want someone putting in that they
have recieved the report if the previous
person didn't show it being sent out.

I tried to due a go to previous record but if
this is the first record (no previous records)
it doesn't work.

Sorry if I've confused anyone (smile). Could
really use the help on this one.

Thanks,
Kelly
 
It's really not wise to do this by looking back at previous records on the
subform. What if the user applied a filter, so he is only seeing a subset of
the table records, on the subform?

You'd be better off looking in the actual table, ignoring what records are
(or are not) shown on the subform. Put code in the BeforeUpdate event of the
subform. This will fire immediately before the user saves a new or edited
record. Then, that code could use a DLookup() function (for example) to look
at existing data in the table. If the new or edited data is not consistent
with the existing records, just display a message, then set the Cancel
parameter of the BeforeUpdate event, to reject the new or edited record
until the user fixes its values.

HTH,
TC
 
TC

Thanks for your help. Just wondering though, could I do it on the subform if I didn't allow for filters on the subform. Then I know the user would be looking at all the records that exist. Just not sure how to stop the macro from going to a previous record if this is the first record being built. It errors out in that case since a previous record doesn't exsist

Think I may have to do an EOF statement but would like to put the "If EOF" statement in a Macro condition instead of sql but not sure how to write the condition

Any ideas?

Thanks
Kelly
 
Well, it's usually best to do things the right way - not the wrong way!

Having said that - here's how you tell if a main form or subform is on the
first record:

(untested)

with me.recordsetclone
.bookmark = me.bookmark
if .absoluteposition = 0 then
msgbox "on first record!"
endif
end with

HTH,
TC


Kelly York said:
TC,

Thanks for your help. Just wondering though, could I do it on the subform
if I didn't allow for filters on the subform. Then I know the user would be
looking at all the records that exist. Just not sure how to stop the macro
from going to a previous record if this is the first record being built. It
errors out in that case since a previous record doesn't exsist.
Think I may have to do an EOF statement but would like to put the "If EOF"
statement in a Macro condition instead of sql but not sure how to write the
condition.
 
Back
Top