PC Review


Reply
Thread Tools Rate Thread

Convert to PDF

 
 
Jacinda
Guest
Posts: n/a
 
      24th Jun 2009

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
 
Reply With Quote
 
 
 
 
Daniel Pineault
Guest
Posts: n/a
 
      25th Jun 2009

' I keep getting an error', what does the error say exactly?

--
Daniel Pineault
http://www.cardaconsultants.com/
For Access Tips and Examples: http://www.devhut.net
Please rate this post using the vote buttons if it was helpful.



"Jacinda" wrote:

> 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

 
Reply With Quote
 
Jacinda
Guest
Posts: n/a
 
      25th Jun 2009

"Compile error: User-defined type not defined"
--
-Jacinda


"Daniel Pineault" wrote:

> ' I keep getting an error', what does the error say exactly?
>
> --
> Daniel Pineault
> http://www.cardaconsultants.com/
> For Access Tips and Examples: http://www.devhut.net
> Please rate this post using the vote buttons if it was helpful.
>
>
>
> "Jacinda" wrote:
>
> > 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

 
Reply With Quote
 
Douglas J. Steele
Guest
Posts: n/a
 
      25th Jun 2009

Do you have a reference set to DAO?

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no private e-mails, please)


"Jacinda" <(E-Mail Removed)> wrote in message
news:90B78053-3A90-49AB-A20B-(E-Mail Removed)...
> "Compile error: User-defined type not defined"
> --
> -Jacinda
>
>
> "Daniel Pineault" wrote:
>
>> ' I keep getting an error', what does the error say exactly?
>>
>> --
>> Daniel Pineault
>> http://www.cardaconsultants.com/
>> For Access Tips and Examples: http://www.devhut.net
>> Please rate this post using the vote buttons if it was helpful.
>>
>>
>>
>> "Jacinda" wrote:
>>
>> > 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



 
Reply With Quote
 
Jacinda
Guest
Posts: n/a
 
      26th Jun 2009

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
--
-Jacinda


"Douglas J. Steele" wrote:

> Do you have a reference set to DAO?
>
> --
> Doug Steele, Microsoft Access MVP
> http://I.Am/DougSteele
> (no private e-mails, please)
>
>
> "Jacinda" <(E-Mail Removed)> wrote in message
> news:90B78053-3A90-49AB-A20B-(E-Mail Removed)...
> > "Compile error: User-defined type not defined"
> > --
> > -Jacinda
> >
> >
> > "Daniel Pineault" wrote:
> >
> >> ' I keep getting an error', what does the error say exactly?
> >>
> >> --
> >> Daniel Pineault
> >> http://www.cardaconsultants.com/
> >> For Access Tips and Examples: http://www.devhut.net
> >> Please rate this post using the vote buttons if it was helpful.
> >>
> >>
> >>
> >> "Jacinda" wrote:
> >>
> >> > 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

>
>
>

 
Reply With Quote
 
Douglas J. Steele
Guest
Posts: n/a
 
      26th Jun 2009

Under Tools | References.

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

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no private e-mails, please)


"Jacinda" <(E-Mail Removed)> wrote in message
news:EE2CBA33-3C55-4407-AA0C-(E-Mail Removed)...
> 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
> --
> -Jacinda
>
>
> "Douglas J. Steele" wrote:
>
>> Do you have a reference set to DAO?
>>
>> --
>> Doug Steele, Microsoft Access MVP
>> http://I.Am/DougSteele
>> (no private e-mails, please)
>>
>>
>> "Jacinda" <(E-Mail Removed)> wrote in message
>> news:90B78053-3A90-49AB-A20B-(E-Mail Removed)...
>> > "Compile error: User-defined type not defined"
>> > --
>> > -Jacinda
>> >
>> >
>> > "Daniel Pineault" wrote:
>> >
>> >> ' I keep getting an error', what does the error say exactly?
>> >>
>> >> --
>> >> Daniel Pineault
>> >> http://www.cardaconsultants.com/
>> >> For Access Tips and Examples: http://www.devhut.net
>> >> Please rate this post using the vote buttons if it was helpful.
>> >>
>> >>
>> >>
>> >> "Jacinda" wrote:
>> >>
>> >> > 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

>>
>>
>>



 
Reply With Quote
 
Graham Mandeno
Guest
Posts: n/a
 
      28th Jun 2009

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!

--
Good Luck :-)

Graham Mandeno [Access MVP]
Auckland, New Zealand

"Jacinda" <(E-Mail Removed)> wrote in message
news:387B70C3-055D-4B07-8764-(E-Mail Removed)...
> 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



 
Reply With Quote
 
Jacinda
Guest
Posts: n/a
 
      29th Jun 2009

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


"Douglas J. Steele" wrote:

> Under Tools | References.
>
> The code you're showing uses DAO. If you don't have a reference set to DAO,
> it won't work.
>
> --
> Doug Steele, Microsoft Access MVP
> http://I.Am/DougSteele
> (no private e-mails, please)
>
>
> "Jacinda" <(E-Mail Removed)> wrote in message
> news:EE2CBA33-3C55-4407-AA0C-(E-Mail Removed)...
> > 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
> > --
> > -Jacinda
> >
> >
> > "Douglas J. Steele" wrote:
> >
> >> Do you have a reference set to DAO?
> >>
> >> --
> >> Doug Steele, Microsoft Access MVP
> >> http://I.Am/DougSteele
> >> (no private e-mails, please)
> >>
> >>
> >> "Jacinda" <(E-Mail Removed)> wrote in message
> >> news:90B78053-3A90-49AB-A20B-(E-Mail Removed)...
> >> > "Compile error: User-defined type not defined"
> >> > --
> >> > -Jacinda
> >> >
> >> >
> >> > "Daniel Pineault" wrote:
> >> >
> >> >> ' I keep getting an error', what does the error say exactly?
> >> >>
> >> >> --
> >> >> Daniel Pineault
> >> >> http://www.cardaconsultants.com/
> >> >> For Access Tips and Examples: http://www.devhut.net
> >> >> Please rate this post using the vote buttons if it was helpful.
> >> >>
> >> >>
> >> >>
> >> >> "Jacinda" wrote:
> >> >>
> >> >> > 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
> >>
> >>
> >>

>
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Convert Columns of Sensitive Information, and then convert back... =?Utf-8?B?V2lsbGlhbSBFbGVyZGluZw==?= Microsoft Excel Programming 1 12th Oct 2006 09:37 PM
IsNumeric: Convert.ToInt32 vs. Convert.ToInt64 sck10 Microsoft ASP .NET 4 3rd Sep 2006 10:40 PM
Convert file to binary, send it over the network, and convert it b =?Utf-8?B?Q2hld2ll?= Microsoft Dot NET 0 9th Sep 2005 06:04 PM
Convert file to binary, send it over the network, and convert it b =?Utf-8?B?Q2hld2ll?= Microsoft Dot NET Framework 1 9th Sep 2005 06:01 PM
convert decimal number to time : convert 1,59 (minutes, dec) to m =?Utf-8?B?YWdlbmRhOTUzMw==?= Microsoft Excel Misc 8 20th Jan 2005 10:24 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:13 AM.