Sub Form Question

  • Thread starter Thread starter aviscomi
  • Start date Start date
A

aviscomi

I have a subfrm that is continous, it contains 4 fields:
comp_num (links to main frm)
date
REG
PREM
PLUS

I would like to have a New Record display at the top of this frm instead of
the bottom and ahve the focus set to the date field. i would also like the
date to be sorted by descending.
Any thoughts?
Thanks!
Anthony
 
aviscomi said:
I have a subfrm that is continous, it contains 4 fields:
comp_num (links to main frm)
date
REG
PREM
PLUS

I would like to have a New Record display at the top of this frm
instead of the bottom and ahve the focus set to the date field. i
would also like the date to be sorted by descending.
Any thoughts?
Thanks!
Anthony

Can't be done with a single form. The new record will always be at the end
(bottom).

You can have two subforms. One set to DataEntry (show only the new record row)
and one with AllowAdditions = No (no new record row) and place the former above
the latter and "sort of" achieve the effect you want.

As for focus just set focus in the Current event of the main form. You will
need to set focus first to the subform and then to the desired control in that
subform.

For the order, base you subform on a query that sports descending on the Date
field.

Also: Rename that field. "Date" is a reserved word and will cause problems for
you. Use RecordDate or similar.
 
thanks!
Rick Brandt said:
Can't be done with a single form. The new record will always be at the
end (bottom).

You can have two subforms. One set to DataEntry (show only the new record
row) and one with AllowAdditions = No (no new record row) and place the
former above the latter and "sort of" achieve the effect you want.

As for focus just set focus in the Current event of the main form. You
will need to set focus first to the subform and then to the desired
control in that subform.

For the order, base you subform on a query that sports descending on the
Date field.

Also: Rename that field. "Date" is a reserved word and will cause
problems for you. Use RecordDate or similar.
 
Can you please provide me with then syntax for setting the focus to the 1st
field of a new record on a sub frm?
 
aviscomi said:
Can you please provide me with then syntax for setting the focus to
the 1st field of a new record on a sub frm?

Me.SubformControlName.SetFocus
Me.SubformControlName.Form.ControlName.SetFocus
 
I've got the following and its not working:
Me.subfrm_Price_Data.SetFocus
Me.subfrm_Price_Data.Form.SDate.SetFocus
 
aviscomi said:
I've got the following and its not working:
Me.subfrm_Price_Data.SetFocus
Me.subfrm_Price_Data.Form.SDate.SetFocus

I just tested identical code and it worked for me. In the above two lines
"subfrm_Price_Data" needs to be the name of the subform *control* found on the
main form. There is no guarantee that the control will have the same name as
the actual form being displayed within.
 
Back
Top