No Data in table, cancel FollowHyperlink

Stacey

Registered User.
Local time
Yesterday, 19:13
Joined
Sep 10, 2002
Messages
84
I have a database that is being used to house data for Mergefields in a Word doc, among other things. The document is in Word because it is about 16 pages long, but only needs the data for about 12 fields. However, the doc has 2 versions, one for the state of TX and one for everyone else.

What I have is a button that runs a macro that has a MkTblQuery to create the table for the TX doc, and a MkTblQuery to create the table for everyone else's doc. Then I have FollowHyperlink "TXtable" and FollowHyperlink "Othertable". However, if one or both of the tables have no data in them, I want the FollowHyperlink part to be skipped and a MsgBox to come up saying "No Data in TXtable", etc.

I have searched the forum, but all I see out there is how to have the MsgBox come up OnNoData for Reports in Access.

Is there a way to do this? I tried a few things with the CancelEvent function, but haven't been able to get it to work. I'm probably just doing it wrong.

DoCmd.RunMacro "McrPrintVendorPcktsALL"
If DCount("*", "TblVendorPcktPrint") = 0 Then DoCmd.CancelEvent
FollowHyperlink "\\cinfile01\gafri\GDC\GDC Tech\GA Plan Operations Projects\Plan Document Automation\Vendor Packet\Vendor packet 3-22-8merged.doc"


I also tried an IIF statement, but it doesn't like the \\ and other things in the path for the word doc.

I think I am out of my depth here. Any help would be appreciated.
 
Go to the properties of the control that has the hyperlink set to it and use the On Error event to trap the error number then use

If Err.Number = nnn Then
.....
End If
 
Thank you for responding.

I went to the command button that kicks off the process, it doesn't have an On Error property.

Right now what happens is if the table created from the MkTbl Query is blank, it just pulls up the doc with no data in the mergefield.
 

Users who are viewing this thread

Back
Top Bottom