I have a subform, which displays in datasheet view (based off a query). I need a piece of code which will loop through all records in the subform.
What the program is supposed to do is go to the main form and throw some info into a word file, then go to the subform (which queries for all related records) and then throw all the related info into the same word file.
The following code works fine. This is taking the main forms info and throwing it into the word file:
.ActiveDocument.Bookmarks("bmk_complainant"
.Select
.Selection.Text=CStr(Forms!frm_complaint!Complainant_Name))
This next part is where it gets tricky. I need to somehow tell the program to increment the bookmark name (make the name a variable ?) and then go through the subform record by record until all the info it thrown into the word file. So, the program would basically be doing this:
Bookmark variable would be incremented.
.ActiveDocument.Bookmarks("bmk_complainant2"
.Select
.Selection.Text = (CStr(Forms!frm_complaint![subfrm_qryRelated].Form.Complainant_Name))
Then it would go to the next record, incrementing the bookmark variable again as well.
.ActiveDocument.Bookmarks("bmk_complainant3"
.Select
.Selection.Text = (CStr(Forms!frm_complaint![subfrm_qryRelated].Form.Complainant_Name))
So that's the idea anyways. The main problems are making a incrementable variable for the bookmark name, and telling it to move to the next record in the subform.
Any help is appreciated :O)
What the program is supposed to do is go to the main form and throw some info into a word file, then go to the subform (which queries for all related records) and then throw all the related info into the same word file.
The following code works fine. This is taking the main forms info and throwing it into the word file:
.ActiveDocument.Bookmarks("bmk_complainant"
.Selection.Text=CStr(Forms!frm_complaint!Complainant_Name))
This next part is where it gets tricky. I need to somehow tell the program to increment the bookmark name (make the name a variable ?) and then go through the subform record by record until all the info it thrown into the word file. So, the program would basically be doing this:
Bookmark variable would be incremented.
.ActiveDocument.Bookmarks("bmk_complainant2"
.Selection.Text = (CStr(Forms!frm_complaint![subfrm_qryRelated].Form.Complainant_Name))
Then it would go to the next record, incrementing the bookmark variable again as well.
.ActiveDocument.Bookmarks("bmk_complainant3"
.Selection.Text = (CStr(Forms!frm_complaint![subfrm_qryRelated].Form.Complainant_Name))
So that's the idea anyways. The main problems are making a incrementable variable for the bookmark name, and telling it to move to the next record in the subform.
Any help is appreciated :O)