Substituting Control Name

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.
 
T

Todd Newell

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
 
P

Paul

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.
 
K

Ken Snell [MVP]

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
 

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