Table Def in Another DB

D

DS

I'm trying to use TableDefs in another DB other than my current DB.
I have a function that finds the other DB as thiscan change.
Here is the function.

Public Function REDACT() As String
Dim strPath As String
strPath = Nz(DLookup("BackName", "tblBackPath", "BackID=1 AND
BackActive=-1"), "")
REDACT = strPath
End Function

Here is my code....
I'm getting the red writing starting with the first line SetDB = CurrentDb
IN
Any help is Appreciated.
Thanks
DS

'PRORED*************************
If Len(REDACT()) > 0 Then
Set DB = CurrentDb IN '" & REDACT() & "'
With DB.TableDefs("tblInfoItem")
.Fields("ItemTaxRateID").DefaultValue = _
Me.TxtTaxRateID
.Fields("ItemTaxRate").DefaultValue = _
Me.TxtTaxRate
With DB.TableDefs("tblInfoMod")
.Fields("ModTaxRateID").DefaultValue = _
Me.TxtTaxRateID
.Fields("ModTaxRate").DefaultValue = _
Me.TxtTaxRate
With DB.TableDefs("tblInfoSubMod")
.Fields("SubModTaxRateID").DefaultValue = _
Me.TxtTaxRateID
.Fields("SubModTaxRate").DefaultValue = _
Me.TxtTaxRate
With DB.TableDefs("tblCheckDetailsTMP")
.Fields("CDTaxRate").DefaultValue = _
Me.TxtTaxRate
End With
End With
End With
End With
Else
End If
'*******************************
 
D

Daniel Pineault

I'm no expert in what you are trying to do, but if you are trying to access
the tabledef of an external database the CurrentDB() is not what you want.

You'd have to try something more along the lines of
Set db = OpenDatabase("DatabasePath\DatabaseName.mdb")
or in your case
Set db = OpenDatabase(REDACT())
--
Hope this helps,

Daniel Pineault
For Access Tips and Examples: http://www.cardaconsultants.com/en/msaccess.php
If this post was helpful, please rate it by using the vote buttons.
 

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

Similar Threads


Top