![]() | |
![]() |
| | Thread Tools | Display Modes |
#11
| |||
| |||
|
|
Any idea why this code fails? Dim t As TableDef Dim s as string Set t = CurrentDb.TableDefs("SomeTableName") s = Mid(t.Connect, 11) 'gets the backend file name It says Object invalid is not longer set. |
#12
| |||
| |||
|
|
If I add a Dim d as database set d = currentdb and modify the Set t line to Set t = d.tabledefs("SomeTableName") it works. Yet if works fine using David's code which was s = Mid(CurrentDB.TableDefs(strTableName).Connect, 11) |
#13
| |||
| |||
|
|
Let me see if I can reproduce that in A2007 ... yes, I can easily reproduce it. Now that I went through the exercise, I do vaguley remember this issue but I no longer remember why it doesn't work. Something about the implicit database variable returned by CurrentDB in memory going out of scope as soon as the statement finishes executing. Change it to Dim t As TableDef Dim s As String Set t = DBEngine(0)(0).TableDefs("tblinvoices") s = Mid(t.Connect, 11) 'gets the backend file name and it works fine |
![]() |
| Thread Tools | |
| Display Modes | |
| |