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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Loading data into sub-form.

Status
Not open for further replies.

Sanibel

Technical User
Nov 15, 2001
73
GB
Hi,

I am trying to load a number of records into a subform "Schedule Codes" from form "Certif" using the followowing code.

Do While Not RS.EOF
With RS
Forms![certif]![schedule codes]![GroupNo] = !GroupNo
Forms![certif]![schedule codes]!
Code:
 = !Code
  Forms![certif]![schedule codes]![Date] = Now()
  Forms![certif]![schedule codes]![GroupNo].SetFocus
  DoCmd.GoToRecord , , acNewRec
  RS.MoveNext                                      
 End With
Loop
RS.Close
Forms![certif].SetFocus

The load works OK execpt that data is only loaded into the first record of the subform and I get a "Can't go to Specified Record" error when the "DoCmd.GoToRecord , , acNewRec" command is executed. I tried to use SetFocus to the subform but get the error "Can't move to the control Schedule Codes". The .SetFocus only seems to work if I enter a field name.

Any help on loadiing data into a subform would be appreciated.
 
What about this ?
Code:
Me.Dirty = False
Forms![certif]![schedule codes].SetFocus
Forms![certif]![schedule codes].Form![GroupNo].SetFocus
Do While Not RS.EOF
 With RS
  Forms![certif]![schedule codes].Form![GroupNo] = !GroupNo
  Forms![certif]![schedule codes].Form![Code] = !Code
  Forms![certif]![schedule codes].Form![Date] = Now()
  Forms![certif]![schedule codes].Form.Dirty = False
  DoCmd.GoToRecord , , acNewRec
  .MoveNext                                      
 End With
Loop

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Thanks for the suggestions. Both run but produce my original problem. Data is loaded into the Schedule Codes form but each load overwrites the first record leaving me with just the last data loaded. I still can't move onto the next record in form Schedule Codes so that all loaded data is displayed.
 
Why not use an append query instead ?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top