Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Entering info into a continous subform

Status
Not open for further replies.

osi2301

Programmer
Jul 3, 2004
75
AU
I have a form with a subform. The subform is a continuous form. The number of records displayed in the subform always varies.

I am attempting to build a button in the main form that when selected would add info into a selected field of each record in the subform. This is a sales/inventory program and the button would mark each item order by the same company as either sold or shipped.

At present, my button will only add the info into the field of the first record of the continuous form but not the others.

Any help with this would be greatly appreciated

 
You can use the RecordsetClone property of the subform.

Code:
'Typed
Dim rs As DAO.Recordset

Set rs=Me.[i][Subform Control Name][/i].Form.RecordsetClone
rs.MoveFirst
Do Until rs.EOF
  rs!Field1=Me.txtText
  rs.MoveNext
Loop

Or you can use an Update query.
 
Thank you very much for the response. Can you explain the significance of the word 'TYPED in the first line? I'm not as well versed in access as I should be but I copied the text into a command button on the main form and substituted the sub form name (Frm_SoldSub) into the third line. It returned the following error.

USER-DEFINED TYPE NOT DEFINED
 
Typed means 'I typed this bit, it is a suggestion, not a tested piece of code.'

You will need a reference to the Microsoft DAO 3.6 Object Library (or 3.something). You will also need to change Field1 to the name of the field you wish to change, and Me.txtText to the name of the control on the form you wish to change it to, or else some value. Furthermore, the loop bit was very much an outline to illustrate how I saw the recordsetclone working, you will need more:

[tt]Do Until rs.EOF
rs.Edit
rs!Field1=Me.txtText 'Control on form
'rs!Field1= "Text" 'The word 'text'
'rs!Field1= #01/01/01# 'A date
'rs!Field1= 2 'A number
'rs!Field1= True 'Yes/No, True/False
rs.Update
rs.MoveNext
Loop[/tt]

This code will change your data, so it is usually best to back-up first.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top