View Full Version : Solved: DAO.Field Lookup Properties
DarkSprout
04-25-2008, 02:52 AM
Please help!
How can I find-out a fields lookup destination on a Foreign table.
With Thanks,
Oorang
04-25-2008, 05:46 AM
I don't think that dao or Access exposes a method to do this. I'd steer you clear of lookup fields in nearly every situation. Give these a read:
http://www.mvps.org/access/lookupfields.htm
http://www.mvps.org/access/tencommandments.htm
DarkSprout
04-25-2008, 06:13 AM
Ta!
I've made a quick and dirty work-around:=
Public Function ReturnForeignName(tblDef As TableDef, obfld As DAO.Field) As String
On Error Resume Next
ReturnForeignName = tblDef.Fields(obfld.Name).Properties("RowSource")
If Err.Number <> 0 Then
ReturnForeignName = ""
Else
If tblDef.Fields(obfld.Name).Properties("RowSourceType") = "Table/Query" Then
'// Clean Query String
ReturnForeignName = RemoveBrackets(Replace(ReturnForeignName, "SELECT", ""))
ReturnForeignName = Left(ReturnForeignName, InStr(1, ReturnForeignName, ",") - 1)
End If
End If
End Function
Private Function RemoveBrackets(ByVal strText As String) As String
RemoveBrackets = Trim(Replace(Replace(Nz(strText, ""), "]", ""), "[", ""))
End Function
Oorang
04-25-2008, 01:24 PM
Sweet, I didn't know you could to that. Good add:)
Powered by vBulletin® Version 4.2.5 Copyright © 2025 vBulletin Solutions Inc. All rights reserved.