Clear Fields in Subform When Form is Open

Robert M

Registered User.
Local time
Today, 10:45
Joined
Jun 25, 2009
Messages
153
I have a form (OfficeSupplies_frm) and subform (OfficeSupplies_sfrm) that I use in keeping track of office supply orders.
My problem is that I am trying to get the subform clear the Order and Qty fields so I do not have double orders.
While the below program works great when the subform is open by itself, when I open the form it clears only the first item in the subform.
The form consists of ITEM and ItemID
The subform consists of ORDER, QTY, ITEM#, ITEM, DESCRIPTION
This is where if I have one Item (I.E. Batteries) I might have many Items
(AA, AAA, C, D, and 9V) So the subform will only show those items that go with the Form's ITEM.
Here is the program as it stands now.

Private Sub Form_Load()
On Err GoTo Oops
Dim db As Database
Dim rs As Recordset
Dim Counter As Integer
Dim Clear
Set db = CurrentDb
Set rs = Me.RecordsetClone
Me.Recordset.MoveLast
Counter = Me.Recordset.RecordCount
[Order].SetFocus
Do While Counter > 0
DoCmd.FindRecord -1
[Order] = 0
Me.Qty = Clear
DoCmd.FindNext
Counter = Counter - 1
Loop
Me.Recordset.MoveFirst
Get_Out:
Exit Sub
Oops:
MsgBox Err.DESCRIPTION
Resume Get_Out
End Sub

I have it under "On Load" in the subform.

Thank you for your time and help in this matter.

Robert M
 
Robert:

Your problem is not how do I clear it but why is it showing up; get rid of that code. Your item form probably has a combo where you select batteries. The value of the combo is the primary key number. This number will also be in the itemtypes table where you list the various sizes of batteries. In the design view of the forms, click on the sub form and get the properties. You will see a link master field and a link child field. The PKs for each table go here. This will synchronize the two on the primary key field, which is what you want.

Also, make sure the properties of the forms do not allow additions and the fields in the sub form do not have default values. When you want to add a new size, you can use another form, or change the additions property of the sub form to yes and a blank line will appear.

Hope this helps
Privateer
 

Users who are viewing this thread

Back
Top Bottom