Continuous form and recordset

G

Guest

I have a main form containing a button to do a search. Clicking this gives a
popup of available records. Selecting one will then populate the main form
(and close the search popup). On the main form also is a subform which
contains correspondence. The subform is set up as a continuous form and what
i am trying to do is populate it. The main form has an ID number and it
should show all records in the continuous form with the same id (ie
correspondance relating to that record) I am trying to do it with the
following code but it shows me only one record (the last one). I want it to
behave like a regular continuous form listing one after the other.... any
ideas? or impossible using this method?

Dim rs As DAO.Recordset
Set rs = CurrentDb.OpenRecordset("SELECT tblAction.ActionIDS,
tblAction.ContactID, tblAction.ActionDate, tblAction.ActionNotes FROM
tblAction WHERE tblAction.ContactID = " & Forms!frmContact!txtSetSchID & ";")
With rs
If .RecordCount > 0 Then
Do Until .EOF
Forms!frmContact!fsubContactAction.Form.txtActionDate = !ActionDate
.MoveNext
Loop
End If
.Close
End With
rs.Close
Set rs = Nothing
 
W

Wayne Morgan

You shouldn't need any code to do this as long as the ID number field is
available in the recordset of the main form and the subform. You then set
the Child and Parent Link Fields properties and Access will do this itself.
The link fields are properties of the subform control on the main form. Open
the main form in design view and open the Properties sheet. Click on the
subform ONE time and go to the Data tab on the Properties sheet. You should
see the link options. The Master is the field on the main form and the Child
is the field on the subform.
 
G

Guest

Thanks. I know there are several ways to do it and I can do it those ways
fine but I would like to know if I can do it this particular way or not, and
if so what the problem is with what i have?
 
W

Wayne Morgan

No, with an unbound continuous form there is really only one of each
control. So, when you fill in the first one, the rest of them will show the
same value. There isn't a way to move from row to row in the unbound
continuous form to place the next value in the next row. To do what you're
trying to do through code, you would need to bind the subform to a stored
query with a parameter pointing to the linking field on the main form
(basically as you are doing with the recordset) and requery the subform in
the Current event of the main form.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top