468,170 Members | 2,058 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,170 developers. It's quick & easy.

How to show records on 2nd subform when 1st subform is activated

I have the following in a form:

- Main Form which stores EE details [Mileage Expense Form]

- 1st subform [SubFSiteInfo] - a continuous form with a combo box which allows either selection of an existing contract or option to open a Contract Form to add.

- 2nd subform [SubFMileageInfo] - a continuous form which shows employee travel information relative to the contract number they are working on at that time.

This all works fine and returns the correct records.

However, when you go back into the form and click on a record on the 1st subform, the related records to not show on the 2nd subform until you click on to the 2nd record of the first subform then click back on to the first record.

I assume that there is something wrong with the requery.

I have the following code in the On Current event of the 1st subform:

Expand|Select|Wrap|Line Numbers
  1. Sub Form_Current()
  2. ' This code created by Form Wizard.
  3.     Dim strParentDocName As String
  4.  
  5.     On Error Resume Next
  6.     strParentDocName = Me.Parent.Name
  7.  
  8.     If Err <> 0 Then
  9.         GoTo Form_Current_Exit
  10.     Else
  11.         On Error GoTo Form_Current_Err
  12.         Me.Parent![SubFMileageInfo].Requery
  13.     End If
  14.  
  15. Form_Current_Exit:
  16.     Exit Sub
  17.  
  18. Form_Current_Err:
  19.     MsgBox Err.Description
  20.     Resume Form_Current_Exit
  21. End Sub
  22.  
Any and all advice would be very much appreciated.

Shona
Nov 10 '10 #1
1 924
TheSmileyCoder
2,321 Expert Mod 2GB
Quote:However, when you go back into the form and
Go back into the form from where? Where have you been and what where you doing? Depending on what you were doing (or not doing) in the meantime the Current might not execute.

2 things to suggest:
  1. Add a (temp) msgbox to your Current event, allowing you to see whether or not it fires at runtime.
  2. Use Private Sub Form_GotFocus() instead

    If neither of these work, you can try uploading the db and I can take a look at it.
Nov 11 '10 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

1 post views Thread by (Pete Cresswell) | last post: by
15 posts views Thread by Joachim | last post: by
reply views Thread by gcreed | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.