What is wrong with my code

louisa

Registered User.
Local time
Today, 15:23
Joined
Jan 27, 2010
Messages
262
Hi everyone,

You will shortly be able to tell that i have never done this before.

When i open my db it is set to open my start up form, from their the only option is to go to the contacts page, however before it does that i am trying to get it to check my form called Network and if the EndDate field is less than 45 days from expiring for it to display the message. Here is what i have.

Private Sub Form_Open(Cancel As Integer)
If DCount("[Contacts]", "[ContactID]", "[Network]", "[EndDate])") < Date - 45 Then
MsgBox "Contract ends in less than 45 days"
End If
End Sub
 
however before it does that i am trying to get it to check my form called Network and if the EndDate field is less than 45 days from expiring for it to display the message.

Personally I would go directly to the database table, rather than try to interrogate / read the field of another form.

It is quite simple to develop such a query. Do you know where exactly that information resides in the database tables?
 
Tbh i have been instructed to complete it this way rather than with a query, but i cannot seem to get it to work.
 
Tbh i have been instructed to complete it this way rather than with a query, but i cannot seem to get it to work.

Whatever...

I question the API you are trying to use to do the lookup. Per the online help, DCount is for:

You can use the DCount function to determine the number of records that are in a specified set of records (a domain ).

At first glance, that does not appear to be the context you are trying to use it in.
 
Well i am hoping that it finds the records that have less than 45 days remaining and possibly says the company name or contact i.d
 
If you had one Network per Contact you would update the Contact record. If you have more than one Network per Contact I would have a subform on Contacts and use conditional formatting to satisfying expiry within 45 days. I rarely use D functions, I thought they were the poor man's database.

Simon
 

Users who are viewing this thread

Back
Top Bottom