Group:  Microsoft Access ยป microsoft.public.access.gettingstarted
Thread: Limiting entries in a data sheet of a form.

DotNetBag
.NET Development Newsgroups

HTVi
TV Discussion Newsgroups

Our Hot Pick: Rising Antivirus 2006 - Certified by TUV & Checkmark! Get 10% discount by entering this coupon code: ONDISCOUNT10
Rising Antivirus 2006

Limiting entries in a data sheet of a form.
"Data" <fahadahmad99[ at ]hotmail.com> 17.07.2006 05:03:58
Hello,

Just have a question. My main form has textbox: name is Condition.
Prefilled by clicking on combo box.

Basically, if the condition is GPM, then user can only enter two
entries in a subform (Orientation form). But if the condition is DBT,
then user can entry up to six entries in the subform (Orientation
form).

I don't know what property of the form(me.etc) to use restrict record
entries in the vba code?


Can anyone help me out.

Thanks

Re: Limiting entries in a data sheet of a form.
"Duane Hookom" <DuaneAtNoSpanHookomDotNet> 17.07.2006 14:42:17
You can add code to the After Insert event of the subform like:

Private Sub Form_AfterInsert()
Dim intAllowRecords as Integer
Select Case Me.Parent.Condition
Case "GPM"
intAllowRecords = 2
Case "DBT"
intAllowRecords = 6
End Select
If Me.RecordsetClone.RecordCount >= intAllowRecords Then
Me.AllowAdditions = False
End If
End Sub

I would actually design a solution with a small lookup table of Conditions
and maximum number of records. I don't like to hard-code the values like
"GPM" and "2".

--
Duane Hookom
MS Access MVP


"Data" <fahadahmad99[ at ]hotmail.com> wrote in message
news:1153112638.685790.280800[ at ]m73g2000cwd.googlegroups.com...
[Quoted Text]
> Hello,
>
> Just have a question. My main form has textbox: name is Condition.
> Prefilled by clicking on combo box.
>
> Basically, if the condition is GPM, then user can only enter two
> entries in a subform (Orientation form). But if the condition is DBT,
> then user can entry up to six entries in the subform (Orientation
> form).
>
> I don't know what property of the form(me.etc) to use restrict record
> entries in the vba code?
>
>
> Can anyone help me out.
>
> Thanks
>


Re: Limiting entries in a data sheet of a form. Another question
"Data" <fahadahmad99[ at ]hotmail.com> 17.07.2006 17:58:22

Thanks so much Duane. Unforunately, the subform is not functioning in
access 2003 on my computer, since not installed.

Another question,

Say in the main form(clients form), textbox(condition field) displays
GPM or DBT.
Instead of subform, user clicks a command button to go to the
orientation form.
This orientation form displays a set amount of records based on the
condition field.

If GPM then displays 2 records to enter data. If DBT the dispays 6
records or entries to enter data.

I am not sure of the code to display in the orientation form,
command click event.

If parent or me.condition = GPM then
'code for number of entries in datasheet in orientation form
If parent or me.condition = DBT then
'code for number of entries in datasheet of orientation form
End If
End If


Also, can you suggest any books for beginning access vba programmers?

Thanks again


Duane Hookom wrote:
[Quoted Text]
> You can add code to the After Insert event of the subform like:
>
> Private Sub Form_AfterInsert()
> Dim intAllowRecords as Integer
> Select Case Me.Parent.Condition
> Case "GPM"
> intAllowRecords = 2
> Case "DBT"
> intAllowRecords = 6
> End Select
> If Me.RecordsetClone.RecordCount >= intAllowRecords Then
> Me.AllowAdditions = False
> End If
> End Sub
>
> I would actually design a solution with a small lookup table of Conditions
> and maximum number of records. I don't like to hard-code the values like
> "GPM" and "2".
>
> --
> Duane Hookom
> MS Access MVP
>
>
> "Data" <fahadahmad99[ at ]hotmail.com> wrote in message
> news:1153112638.685790.280800[ at ]m73g2000cwd.googlegroups.com...
> > Hello,
> >
> > Just have a question. My main form has textbox: name is Condition.
> > Prefilled by clicking on combo box.
> >
> > Basically, if the condition is GPM, then user can only enter two
> > entries in a subform (Orientation form). But if the condition is DBT,
> > then user can entry up to six entries in the subform (Orientation
> > form).
> >
> > I don't know what property of the form(me.etc) to use restrict record
> > entries in the vba code?
> >
> >
> > Can anyone help me out.
> >
> > Thanks
> >

Re: Limiting entries in a data sheet of a form. Another question
"Duane Hookom" <DuaneAtNoSpanHookomDotNet> 17.07.2006 21:20:10
I'm not sure why you think the subform is not installed?

If I understand, your code would be similar to the suggested code except you
would replace
Me.Parent.Condition
with
Forms!Clients!Condition


--
Duane Hookom
MS Access MVP



"Data" <fahadahmad99[ at ]hotmail.com> wrote in message
news:1153159102.910784.159940[ at ]p79g2000cwp.googlegroups.com...
[Quoted Text]
>
> Thanks so much Duane. Unforunately, the subform is not functioning in
> access 2003 on my computer, since not installed.
>
> Another question,
>
> Say in the main form(clients form), textbox(condition field) displays
> GPM or DBT.
> Instead of subform, user clicks a command button to go to the
> orientation form.
> This orientation form displays a set amount of records based on the
> condition field.
>
> If GPM then displays 2 records to enter data. If DBT the dispays 6
> records or entries to enter data.
>
> I am not sure of the code to display in the orientation form,
> command click event.
>
> If parent or me.condition = GPM then
> 'code for number of entries in datasheet in orientation form
> If parent or me.condition = DBT then
> 'code for number of entries in datasheet of orientation form
> End If
> End If
>
>
> Also, can you suggest any books for beginning access vba programmers?
>
> Thanks again
>
>
> Duane Hookom wrote:
>> You can add code to the After Insert event of the subform like:
>>
>> Private Sub Form_AfterInsert()
>> Dim intAllowRecords as Integer
>> Select Case Me.Parent.Condition
>> Case "GPM"
>> intAllowRecords = 2
>> Case "DBT"
>> intAllowRecords = 6
>> End Select
>> If Me.RecordsetClone.RecordCount >= intAllowRecords Then
>> Me.AllowAdditions = False
>> End If
>> End Sub
>>
>> I would actually design a solution with a small lookup table of
>> Conditions
>> and maximum number of records. I don't like to hard-code the values like
>> "GPM" and "2".
>>
>> --
>> Duane Hookom
>> MS Access MVP
>>
>>
>> "Data" <fahadahmad99[ at ]hotmail.com> wrote in message
>> news:1153112638.685790.280800[ at ]m73g2000cwd.googlegroups.com...
>> > Hello,
>> >
>> > Just have a question. My main form has textbox: name is Condition.
>> > Prefilled by clicking on combo box.
>> >
>> > Basically, if the condition is GPM, then user can only enter two
>> > entries in a subform (Orientation form). But if the condition is DBT,
>> > then user can entry up to six entries in the subform (Orientation
>> > form).
>> >
>> > I don't know what property of the form(me.etc) to use restrict record
>> > entries in the vba code?
>> >
>> >
>> > Can anyone help me out.
>> >
>> > Thanks
>> >
>


Home | Search | Terms | Imprint | Contact
Newsgroups Reader - provided by WiredBox.Net