Convert to PDF

J

Jacinda

Hi, I imported this from http://www.lebans.com/reporttopdf.htm... this is
just a piece of the code... I keep getting an error on this part of the code:

Public Function TdfSetOk(db As DAO.Database, tdf As DAO.TableDef, ctl As
Control, strErrMsg As String) As Boolean
On Error GoTo Err_Handler
'Purpose: Set the TableDef passed in, using the name in the Caption in
the control's attached label.
'Return: True on success. (Fails if the caption is an alias.)
'Arguments: db = database variable (must already be set).
' tdf = the TableDef variable to be set.
' ctl = the control that has the name of the table in its
attached label.
' strMsg = string to append any error messages to.
Dim strTable As String 'The name of the table.

strTable = ctl.Controls(0).Caption 'Get the name of the table from the
attached label's caption.
Set tdf = db.TableDefs(strTable) 'Fails if the caption is an alias.
TdfSetOk = True 'Return true if it all worked.

Exit_Handler:
Exit Function

Err_Handler:
Select Case Err.Number
Case 3265& 'Item not found in collection. (Table name is an alias.)
strErrMsg = strErrMsg & "Skipped table " & strTable & vbCrLf
Case Else
strErrMsg = strErrMsg & "Error " & Err.Number & ": " &
Err.Description & vbCrLf
End Select
Resume Exit_Handler
End Function
--

I have used the whole code in another database with success, but now when I
tried it in another db I am having a problem... I'm confused about what label
name this is referring to... Help :)
-Jacinda
 
J

Jacinda

I'm not real sure where to find the answer to your question...
are you talking about in Tools- refrences?... or in the code itself...

I didn't write the code, I just copied it... it works in one of my othe db,
without a problem, I don't know why it won't work in this particular db
 
D

Douglas J. Steele

Under Tools | References.

The code you're showing uses DAO. If you don't have a reference set to DAO,
it won't work.
 
G

Graham Mandeno

Hi Jacinda

If I recall correctly, this function is used only for generating a PDF of
the relationships diagram.

If your project does not use DAO and you have no need of that capability,
then you can just delete that function (and any other code that refers to
it).

I see no point in adding a DAO reference just to satisfy some declarations
in a bit of code you don't use!
 
J

Jacinda

Thanks to all who replied... Douglas that was the answer, I appreciate it...

Dale, I do have the add on- but this code is really neat because it saves
those "save-as" steps...

Graham... I'll have to look furhter into what you were refering to.


Again thanks to all...
 

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