Simple SubForm Question.......

Les Blair

Registered User.
Local time
Yesterday, 22:54
Joined
Sep 10, 2007
Messages
49
I have a Form it is called frmSoldCase. On this form is a subform called frmRevisions.
I have a Date field that I need to put some code behind to check the date:

Dim dteDate As Date

'MsgBox "Received Date = " & [Received Date]
dteDate = [Forms]![frmRevisions].[Received Date]
dteDate = GetBusinessDate(dteDate, 0, icFuture)
dteDate = AdjustDate(dteDate, icFuture)
Me.Received_Date.Value = dteDate

Access keeps telling me that it can not find the form. I have tried to find an example of referring to a field on a Subform from a Form but have not found one or one that I can understand. Please can someone tell this dumb person how to reference a subform from a form.:o:confused:
 
forms!frmSoldCase.frmRevisions.form![Received Date]

Provided the subform control 'Name' on the form frmSoldCase is 'frmRevisions'

:)
ken
 
Ken's right. A little background is that only the main form appears in the forms collection. When a subform appears on a main form, access treats it almost as if it's a fancy control rather than a form.
 
Thanks,

I have learn a lot today. Today was a great day!
 
One more question on Simple Subform Question.......

That worked great!

Now the same subform is used on a different form. is there an easy way to tell which form is open. Say, could I use a 'If' statement and if so how. I used the following and it gave me the following results.

If [Forms]![frmSBDProspects] Then
dteDate = [Forms]![frmSBDProspects].[frmRevisions subform].[Form]![Med Rev Date Rec]
ElseIf [Forms]![frmMEDProspects] Then
dteDate = [Forms]![frmMEDProspects].[frmRevisions subform].[Form]![Med Rev Date Rec]
End If

the results was an error stating that Access could not find form frmSBDProspects. I am currently on form frmMEDProspects. I use this same revision subform on 2 other forms also.
 
If this code is in then main form then hard code it for each main form. If the code is in the subform can't you simply use:

dteDate = me![Med Rev Date Rec]

???
ken
 
Thanks, that did it. It now works on all the forms......
 

Users who are viewing this thread

Back
Top Bottom