Access 2000 - Macro

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I need the code for a macro that will try to Find "#Num!" without the quotes,
within a field called 'Date'. If it finds #Num! then Quit the database. If
it doesn't find #Num! then stay in the database.

Can this be done?

Many thanks in advance.
 
Richard,

Use a macro with the Quit action. In the Condition for this action, put
the equivalent of this...
DCount("*","YourTable","[Date]='#Num!'")>0

If you can't see the Condition column in the macro design window, select
it from the View menu.

As an aside, 'Date' is a 'Reserved Word' in Access (i.e. has a special
meaning), and as such it is not a good idea to use this as the name of a
field or control or database object.

Now, you may need to explain your purpose or your problem a little
further. If you are seeing #NUM! in your database, it indicates an
error or corruption. It is not data as such, and will not be searchable
as data would be. So I suspect your question may turn out to not really
help solve the problem.
 
Thanks Steve

Using the condition with Quit has resolved my problem. I did however change
the criteria from #Num! to Yes or No or N/A and use the Name field instead of
Date.

To explain:
I have an online form (Intranet) that submits information and is emailed
into an Outlook inbox. The emails are linked to an Access 2000 database on a
network drive. The problem is the data in the database gets all messed up
when opened. So info that should be in one field is actually in another. I
have found that if the emails are slightly amended as they come into the
inbox then all is ok. So I have created a macro in Outlook, with help, that
removes an inserted phrase that is not needed. I have used your macro to
display a message box to the user that they need to run the macro in Outlook,
the database then exits. The user runs the macro in Outlook and goes back
into the database on the network drive and all is ok.

One again, thank you for your help.
--
Richard


Steve Schapel said:
Richard,

Use a macro with the Quit action. In the Condition for this action, put
the equivalent of this...
DCount("*","YourTable","[Date]='#Num!'")>0

If you can't see the Condition column in the macro design window, select
it from the View menu.

As an aside, 'Date' is a 'Reserved Word' in Access (i.e. has a special
meaning), and as such it is not a good idea to use this as the name of a
field or control or database object.

Now, you may need to explain your purpose or your problem a little
further. If you are seeing #NUM! in your database, it indicates an
error or corruption. It is not data as such, and will not be searchable
as data would be. So I suspect your question may turn out to not really
help solve the problem.

--
Steve Schapel, Microsoft Access MVP

I need the code for a macro that will try to Find "#Num!" without the quotes,
within a field called 'Date'. If it finds #Num! then Quit the database. If
it doesn't find #Num! then stay in the database.

Can this be done?

Many thanks in advance.
 
Back
Top