MS Access 2002 SP 3
I have two forms, one with a combo box looking at available lookup tables and the other an unbound form which will be used by the user to update lookup values.
The lookup value tables all have the same format: ID, Value, ValidFrom, ValidTo
The code I use to get the form to look at the correct lookup value table is:
Dim db As Database
Dim tdfTable As TableDef
Dim strTableName As String
strTableName = Me![cmbLookupTables].Value
Set db = CurrentDb()
Set tdfTable = db.TableDefs(strTableName)
If IsNull(Me![cmbLookupTables]) Then
MsgBox "No selection."
Else
DoCmd.OpenForm "frmLookUpTablesAdministration"
'Get the fields for the SQL query
Dim strID As String
Dim strValue As String
strID = tdfTable.Fields(0).Name
strValue = tdfTable.Fields(1).Name
Forms!frmLookUpTablesAdministration.Caption = "Edit List for " & Me![cmbLookupTables].Column(1)
Forms![frmLookUpTablesAdministration].RecordSource = "SELECT [" & strID & "] AS tblID,[" _
& strValue & "] AS tblDescription,[" _
& strValidFrom & "],[" _
& strValidTo & "]" _
& " FROM " & strTableName & ";"
Forms![frmLookUpTablesAdministration].Requery
Forms!frmLookUpTablesAdministration.Repaint
Forms!frmLookUpTablesAdministration.Refresh
End If
The values on the edit form are being set correctly and the correct number of records returned. However, the fields are not visible (have checked the visible property is set to yes) even though in the properties window I can scroll through each field and check the properties have been set correctly.
Any ideas where I am going wrong?