You posted this same question in the forms group. Newsgroup courtesy is
that you cross post (one message to several groups) when necessary, but
that
you do not multi-post (separate messages to several groups).
http://www.mvps.org/access/netiquette.htm
Dave,
I tried it and I got a run time error 438: Object does not support this
property or method. I don't know what I did - I plugged in my control
name
where you specified. I have tried everything I could think of and
googled
this all day. I give up! I'll have them type 1, 2, 3...
Thanks for your help. I notice you help lots of confused souls...
Amy - I tried yours too... didn't work but thanks anyway.
Heid
:
Okay, here is a way to do both. Use the Current event of the subform.
Check
to see if the current record is a new record. If it is, get the
highest
number. If the number is > 10, present a message box and undo the
record.
Private Sub Form_Current()
Dim lngSampleNumber As Long
If Me.NewRecord Then
lngSampleNumber = NextSampleNumber
If lngSampleNumber > 10 Then
MsgBox "Only 10 Samples per Catch are Allowed",
vbExclamation
Me.Undo
Else
'txtSampleNumber is made up. Use the name of your control on your
form.
Me.txtSampleNumber = lngSampleNumber
End If
End If
End Sub
**************
Here is a function you can paste into your form module that finds the
highest sample number in the current catch.
Private Function NextSampleNumber() As Long
Dim lngHighSample As Long
With Forms!MyFormName!MySubformControlName.Form.RecordsetClone
.MoveFirst
lngHighSample = !SampleNumber
.MoveNext
Do While Not .EOF
If !SampleNumber > lngHighSample Then
lngHighSample = !SampleNumber
End If
.MoveNext
Loop
End With
NextSampleNumber = lngHighSample + 1
End Function
--
Dave Hargis, Microsoft Access MVP
:
it could be a restriction on the table that prevents them from
entering
10.
And I wanted this to automatically populate so there is not a chance
of
them
entering, lets say, "2" twice.
:
How do you prevent them from putting in Sample 11 is the question.
--
Dave Hargis, Microsoft Access MVP
:
At the 10th sample, the user will either exit the program or
enter
another
catch. If they begin to enter another catch, there will be 10
samples to
enter along with that catch.
:
What you don't say is what you want to happen when you hit 10
samples.
--
Dave Hargis, Microsoft Access MVP
:
I have a form [CATCH] with a subform [SAMPLE]. Each time I
enter a new
catch, I need the sample number to start over at 1 and
progress
to 10 (we
always enter 10 samples for each catch). So, my SAMPLE
table
will look like
this:
AutoNum CatchID SampleNumber
1 1 1
2 1 2
3 1 3...
4 2 1
5 2 2
6 2 3...