Re: subform records
- From: Arash kamankesh <Arashkamankesh@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Sat, 12 Aug 2006 11:58:02 -0700
"Allen Browne" wrote:
Reply posted to your thread yesterday:
Group: microsoft.public.access.forms
Subject: total records of nested subforms in a form
Cancel the BeforeInsert event of the innermost subform if there are already
14 items in the order.
Presumably you have 3 tables here:
- tblOrder, with OrderID primary key
- tblSet, with SetID primary key, and OrderID foreign key.
- tblItem, with ItemID primary key, and SetID foreign key.
Private Sub Form_BeforeInsert(Cancel As Integer)
Dim rs As DAO.Recordset
Dim strSql as String
Const lngcMaxItem As Long = 14
With Me.Parent
If .NewRecord Then
Cancel = True
MsgBox "Enter a record in the previous form first."
Else
strSql = "SELECT Count(tblItem.ItemID) AS ItemCount " & _
"FROM tblSet INNER JOIN tblItem ON tblSet.SetID =
tblItem.SetID " & _
"WHERE tblSet.OrderID = " & ![OrderID] & ";"
Set rs = dbengine(0)(0).OpenRecordset(strSql)
If rs.RecordCount > 0 Then
If rs!ItemCount >= lngcMaxItem Then
Cancel = True
MsgBox "No more!"
End If
End If
rs.Close
End If
End With
End Sub
--
--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.
"Arash kamankesh" <Arashkamankesh@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in
message
news:68F97352-12C5-4DC1-9D03-6FCAF8ECDB48@xxxxxxxxxxxxxxxx
hi
"Allen Browne" wrote:
Answered in one of the other threads where you asked this question.i can't find it because i have not recived any notification about that
hi
i just can find this answer
can you help me again please
thanks
i entered the code as you told but i encountered this error:" run-time error '3075' :
syntax error (missing operator) in query expression
'count(tblItem.itemID)'."
i notify that
"itemID" &"setID" are autonumber as primery key
and "orderID" has number format
("sorry for bad english speaking")
thanks
.
- Follow-Ups:
- Re: subform records
- From: Allen Browne
- Re: subform records
- References:
- Re: subform records
- From: Allen Browne
- Re: subform records
- From: Allen Browne
- Re: subform records
- Prev by Date: Re: Display totals on a form
- Next by Date: Re: look for records in a form
- Previous by thread: Re: subform records
- Next by thread: Re: subform records
- Index(es):
Relevant Pages
|
Loading