View Full Version : Nested Subform Reset Focus to Main Form - Help!


Jackie
02-25-2001, 09:54 AM
I am suppose to have this database delivered tomorrow at 8am. All is completed but I am having problems with my form.

Problem 1:
Mainform = RepairLogEntry
Subform = AutoInfo
Nested Subform (in AutoInfo) = CustInfo

When I leave the last field on CustInfo I need the focus to go back to the mainform, RepairLogEntry, first control (DistCenter), next record.

I have searched this forum and the only thing I found was as Microsoft site with code written. I am not good with code and cannot seem to get this to work.

Private Sub Discount_Exit(Cancel As Integer)

On Error Goto Error_Routine

Dim RS As Recordset
Set RS = Me.RecordsetClone
RS.MoveLast
If StrComp(Me.Bookmark, rs.Bookmark, 0) = 0 Then
Forms![RepairLogEntry]![DistCenter].SetFocus
' The following line may be removed in version 2.0
Forms![RepairLogEntry]![AutoInfo Subform].Requery
End If
Exit Sub

Error_Routine:
MsgBox "You must be on a record with data"
Exit Sub
End Sub


Do I just have a control not in the right place? Or not even close to getting it right?

Problem 2:
When a search on the form is preformed and the record appears I would like it to be the latest record to date. I am receiving the oldest. Is there a way I can change this?

In advance, thank you very much!

Jackie

Jack Cowley
02-25-2001, 12:48 PM
Is the last field on your subsubform named Discount? If not then you want to place your code in the On Exit event of the last field in that form. I asked because the sample code you used is based on a field called Discount.

I am not sure how you are searching your form but if it is based on a query you can set the sorting based on the date rather than something else.

Hope this helps a little.

Jack

Jackie
02-25-2001, 02:26 PM
Jack,

Thank you for your reply. I copy and pasted from the website and neglected to change "discount" to "refi" on this post. Since I do not understand code I have tried placing it in all subforms (changing criteria as needed) "on exit", and on the field "refi" in the custinfo form. I am just totall clueless as to what I am doing wrong.

For searching, the form is not based on a query. I need to be able to add, delete and edit the information so I didn't use a query.

I really appreciate any insight you can give me. Thanks!