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