navigating records in subform

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a form (frmMain) with a subform (sfLabValues). In the subform I enter
lab values on different dates.

What are my options to review the Lab results i.e how to navigate through
the records in the subform? Any ideas would be greatly appreciated. Thanks

S Kahn

PS: Pls be aware that my programming skills are rather limited!
 
For what end?

The domain aggregate functions give you basic statistical info, e.g.:
DAvg(), DCount(), DLookup(), DMin(), DMax(), DStDev(), DSum(), DVar().

You can also sum or average the values into controls in the Form Footer
section of the subform. Use a Continuous View subform to show the results.

If you are trying to alter all related values, you could execute an Update
query, and then requery the subform. This example runs from the main form
where FK is the foreign key in the subform's table, and PK is the matching
numeric primary key in the main form:
Dim strSql As String
strSql = "UPDATE MySubformTable SET IsPicked = False WHERE (FK = " &
Me.PK & ") AND (IsPicked = True);"
dbEngine(0)(0).Execute strSql, dbFailOnError
Me.[NameOfYourSubformControlHere].Requery

If you need to loop through the records anyway, you can use the
RecordsetClone of the subform. If the subform is filtered, the clone set
will also be filtered, so may not give full results.

The code from the main form would look something like this:
With Me.[NameOfYourSubformControlHere].Form.RecordsetClone
If .RecordCount > 0 Then
.MoveFirst
Do While Not .EOF
'do something here.
.MoveNext
Loop
End If
End Sub
 
Thanks for the input.

As to why I want to do that? I want to be able to review the previous Lab
results as I am making rounds on my patients.

The last option would help i.e looping through the records but I was hoping
to have a Combo box with the dates of the results. Then if I could select a
date / date range etc it would pull up the selected records!

Thanks again

S Kahn

Allen Browne said:
For what end?

The domain aggregate functions give you basic statistical info, e.g.:
DAvg(), DCount(), DLookup(), DMin(), DMax(), DStDev(), DSum(), DVar().

You can also sum or average the values into controls in the Form Footer
section of the subform. Use a Continuous View subform to show the results.

If you are trying to alter all related values, you could execute an Update
query, and then requery the subform. This example runs from the main form
where FK is the foreign key in the subform's table, and PK is the matching
numeric primary key in the main form:
Dim strSql As String
strSql = "UPDATE MySubformTable SET IsPicked = False WHERE (FK = " &
Me.PK & ") AND (IsPicked = True);"
dbEngine(0)(0).Execute strSql, dbFailOnError
Me.[NameOfYourSubformControlHere].Requery

If you need to loop through the records anyway, you can use the
RecordsetClone of the subform. If the subform is filtered, the clone set
will also be filtered, so may not give full results.

The code from the main form would look something like this:
With Me.[NameOfYourSubformControlHere].Form.RecordsetClone
If .RecordCount > 0 Then
.MoveFirst
Do While Not .EOF
'do something here.
.MoveNext
Loop
End If
End Sub

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

S Kahn said:
I have a form (frmMain) with a subform (sfLabValues). In the subform I
enter
lab values on different dates.

What are my options to review the Lab results i.e how to navigate through
the records in the subform? Any ideas would be greatly appreciated. Thanks

S Kahn

PS: Pls be aware that my programming skills are rather limited!
 
Okay. You could also apply a Filter to a subform to show the related records
in a date range.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

S Kahn said:
Thanks for the input.

As to why I want to do that? I want to be able to review the previous Lab
results as I am making rounds on my patients.

The last option would help i.e looping through the records but I was
hoping
to have a Combo box with the dates of the results. Then if I could select
a
date / date range etc it would pull up the selected records!

Thanks again

S Kahn

Allen Browne said:
For what end?

The domain aggregate functions give you basic statistical info, e.g.:
DAvg(), DCount(), DLookup(), DMin(), DMax(), DStDev(), DSum(), DVar().

You can also sum or average the values into controls in the Form Footer
section of the subform. Use a Continuous View subform to show the
results.

If you are trying to alter all related values, you could execute an
Update
query, and then requery the subform. This example runs from the main form
where FK is the foreign key in the subform's table, and PK is the
matching
numeric primary key in the main form:
Dim strSql As String
strSql = "UPDATE MySubformTable SET IsPicked = False WHERE (FK = " &
Me.PK & ") AND (IsPicked = True);"
dbEngine(0)(0).Execute strSql, dbFailOnError
Me.[NameOfYourSubformControlHere].Requery

If you need to loop through the records anyway, you can use the
RecordsetClone of the subform. If the subform is filtered, the clone set
will also be filtered, so may not give full results.

The code from the main form would look something like this:
With Me.[NameOfYourSubformControlHere].Form.RecordsetClone
If .RecordCount > 0 Then
.MoveFirst
Do While Not .EOF
'do something here.
.MoveNext
Loop
End If
End Sub


S Kahn said:
I have a form (frmMain) with a subform (sfLabValues). In the subform I
enter
lab values on different dates.

What are my options to review the Lab results i.e how to navigate
through
the records in the subform? Any ideas would be greatly appreciated.
Thanks

S Kahn

PS: Pls be aware that my programming skills are rather limited!
 
Thanks, I will try that.
SK

Allen Browne said:
Okay. You could also apply a Filter to a subform to show the related records
in a date range.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

S Kahn said:
Thanks for the input.

As to why I want to do that? I want to be able to review the previous Lab
results as I am making rounds on my patients.

The last option would help i.e looping through the records but I was
hoping
to have a Combo box with the dates of the results. Then if I could select
a
date / date range etc it would pull up the selected records!

Thanks again

S Kahn

Allen Browne said:
For what end?

The domain aggregate functions give you basic statistical info, e.g.:
DAvg(), DCount(), DLookup(), DMin(), DMax(), DStDev(), DSum(), DVar().

You can also sum or average the values into controls in the Form Footer
section of the subform. Use a Continuous View subform to show the
results.

If you are trying to alter all related values, you could execute an
Update
query, and then requery the subform. This example runs from the main form
where FK is the foreign key in the subform's table, and PK is the
matching
numeric primary key in the main form:
Dim strSql As String
strSql = "UPDATE MySubformTable SET IsPicked = False WHERE (FK = " &
Me.PK & ") AND (IsPicked = True);"
dbEngine(0)(0).Execute strSql, dbFailOnError
Me.[NameOfYourSubformControlHere].Requery

If you need to loop through the records anyway, you can use the
RecordsetClone of the subform. If the subform is filtered, the clone set
will also be filtered, so may not give full results.

The code from the main form would look something like this:
With Me.[NameOfYourSubformControlHere].Form.RecordsetClone
If .RecordCount > 0 Then
.MoveFirst
Do While Not .EOF
'do something here.
.MoveNext
Loop
End If
End Sub


I have a form (frmMain) with a subform (sfLabValues). In the subform I
enter
lab values on different dates.

What are my options to review the Lab results i.e how to navigate
through
the records in the subform? Any ideas would be greatly appreciated.
Thanks

S Kahn

PS: Pls be aware that my programming skills are rather limited!
 
Back
Top