Substituting Control Name

  • Thread starter Thread starter Todd Newell
  • Start date Start date
T

Todd Newell

I have a form from which I call reports. The reports are
defined in a table with some required criteria controls
on the calling form. I'm trying to check to make sure
the controls have been filled in prior to calling the
reports. I cannot determine how to test the values in
the form's controls given the control names in a table.
 
Thanks for the quick response.

I'm trying to use this in a statement that would look like

Dim rst as New ADODB
rst.Source = "Select ctlName from tblCtls"
rst.Open

If Me.Controls(rst.Fields("ctlName")) > 3/14/2004 Then
Do Something
End If

rst.Fields("ctlName") returns the correct control name,
however, it is not beeing evaluated. I think I need to
use the Eval function.

Todd
 
You made need to convert to date:

cdate(Me.Controls(rst.Fields("ctlName")) > cdate("3/14/2004")

Watch out for US vs International date formats as well.
 
Assuming that the control is a date/time formatted control, you must delimit
the "hard-coded" date value with # characters so that ACCESS interprets
3/14/2004 as a date and not three divided by 14 divided by 2004:

If Me.Controls(rst.Fields("ctlName")) > #3/14/2004# Then
Do Something
End If
 
Back
Top