Form Subfrm References

  • Thread starter smcgrath via AccessMonster.com
  • Start date
S

smcgrath via AccessMonster.com

I have a main Form that I want the account number field to stand out
(different color) if the returned date for the file is blank on the subfrm.
I am using the following in the on current of the main form and I am getting
an error - what would be the correct reference?


If Me.FolderOutSubFrm.Form.[ReturnedDate] = "" Then
Me.SortAcct.BackColor = vbRed
Else
Me.SortAcct.BackColor = vbWhite
End If
 
M

Marshall Barton

smcgrath said:
I have a main Form that I want the account number field to stand out
(different color) if the returned date for the file is blank on the subfrm.
I am using the following in the on current of the main form and I am getting
an error - what would be the correct reference?


If Me.FolderOutSubFrm.Form.[ReturnedDate] = "" Then
Me.SortAcct.BackColor = vbRed
Else
Me.SortAcct.BackColor = vbWhite
End If


That appears to be a valid reference. Are you sure the
subform actually has a record to reference? Maybe you need
to use:

With Me.FolderOutSubFrm.Form
If .RecordsetClone.RecordCount > 0 Then
If .[ReturnedDate] = "" Then
Me.SortAcct.BackColor = vbRed
Else
Me.SortAcct.BackColor = vbWhite
End If
End If
End With
 
S

smcgrath via AccessMonster.com

yes there is a record to reference to and I still can't get either one to
work.

Marshall said:
I have a main Form that I want the account number field to stand out
(different color) if the returned date for the file is blank on the subfrm.
[quoted text clipped - 6 lines]
Me.SortAcct.BackColor = vbWhite
End If

That appears to be a valid reference. Are you sure the
subform actually has a record to reference? Maybe you need
to use:

With Me.FolderOutSubFrm.Form
If .RecordsetClone.RecordCount > 0 Then
If .[ReturnedDate] = "" Then
Me.SortAcct.BackColor = vbRed
Else
Me.SortAcct.BackColor = vbWhite
End If
End If
End With
 
M

Marshall Barton

smcgrath said:
yes there is a record to reference to and I still can't get either one to
work.


Then maybe we're suffering from a word usage
misunderstanding. By "blank", you might have meant Null.
Actually, I should have picked up on that since the field's
name implies that it's a date field and not a text field.

Try this instead:

With Me.FolderOutSubFrm.Form
If .RecordsetClone.RecordCount > 0 Then
If IsNull(.ReturnedDate) Then
Me.SortAcct.BackColor = vbRed
Else
Me.SortAcct.BackColor = vbWhite
End If
End If
End With
 
G

Guest

Try this:


If IsNull(Forms![nameofmainform]![FolderOutSubFrm].Form![ReturneDate]) =
True Then

Me.SortAcct.BackColor = vbRed
Else
Me.SortAcct.BackColor = vbWhite

End If
 
S

smcgrath via AccessMonster.com

Still can't get it to work - incorrect reference to form/report error -
Should I be putting this code on the on current of the Main form or the
subform?

Dan said:
Try this:

If IsNull(Forms![nameofmainform]![FolderOutSubFrm].Form![ReturneDate]) =
True Then

Me.SortAcct.BackColor = vbRed
Else
Me.SortAcct.BackColor = vbWhite

End If
I have a main Form that I want the account number field to stand out
(different color) if the returned date for the file is blank on the subfrm.
[quoted text clipped - 6 lines]
Me.SortAcct.BackColor = vbWhite
End If
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top