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

moveing to next record .. cont.

Status
Not open for further replies.

jeffmoore

Programmer
Aug 29, 2003
301
US
this code works great if I set a breakpoint at the while stmt and step thru it....
It puts a value in my txtbox "txt_trainingtype and then moves to the next record and does the same.
BUT
when I let the code run without steping thru it, it won't move to the next record AND the only values that appear in the txtbox are the 1st and 3rd.

Set rs = Me.Recordset
rs.MoveFirst
Forms!frm_Training_Matrix![qry_Training_Details_Sub subform].SetFocus

Forms![frm_Training_Matrix]![qry_Training_Details_Sub subform].Form![txt_TrainingType].SetFocus

While Not rs.EOF

Forms!frm_Training_Matrix![qry_Training_Details_Sub subform]!txt_TrainingType = rs!TrainingType

Forms![frm_Training_Matrix]![qry_Training_Details_Sub subform].Form![txt_TrainingType].SetFocus

DoCmd.GoToRecord , , acNext

rs.MoveNext

Wend
 
Try using the subform recordset, and the field the mentioned control is bound to:

[tt]dim rs as dao.recordset
dim rssub as dao.recordset
set rs=me.recordsetclone
set rssub=me![qry_Training_Details_Sub subform].form.recordset
rs.movefirst
rssub.movefirst
do while not rs.eof and not rssub.eof
rssub.edit
rssub!trainingtype= rs!TrainingType
rssub.update
rssub.movenext
rs.movenext
loop
set rs=nothing
set rssub=nothing
me.requery
me![qry_Training_Details_Sub.form.requery[/tt]

But - 1 this would probably run faster/better using queries than this method 2 storing the same values in two tables might indicate the table structure isn't fully normalized - and would the subform and main form have the excact same number of records?

- as usual, typed not tested

Roy-Vidar
 
jeffmoore,
judging by the name, of both forms, I'm assuming that the subform is linked to the main form, but judging by your procedure, I would assume otherwise.

My point is, if linked, you will not need to force movement between records, of the subform.
This may suffice...

Dim rs As Recordset
Set rs = Me.Recordset
Do Until rs.EOF
Forms!frm_Training_Matrix![qry_Training_Details_Sub subform]!txt_TrainingType = rs!TrainingType
rs.MoveNext
Loop

...but again, Judging by your & Roy's post, I'm thinking this may not be the case?

But, in case it is...

Good luck, either way!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top