I create tables in the database to store project files. I've been testing a method of connecting to these tables (ex. tblTest1) from a Form using Recordset and displaying a single field in a textbox, see below:
------------------------------
This works. However, when I try to create an InputBox to allow the user to select the specific table, It doesn't work. Sample code below. What am I doing wrong?
---------------------------
---------------------
Code:
Private Sub Form_Open(Cancel As Integer)
Dim rs As Recordset
Set rs = CurrentDb.OpenRecordset("SELECT * from tblTest1")
Set Me.Recordset = rs
Me.txtDiscipline.ControlSource = "Discipline"
End Sub
This works. However, when I try to create an InputBox to allow the user to select the specific table, It doesn't work. Sample code below. What am I doing wrong?
---------------------------
Code:
Private Sub Form_Open(Cancel As Integer)
Dim tblFile As String
Dim rs As Recordset
tblFile = InputBox("Enter the name of the Project File ex. tbl_FileName")
If Len(tblFile) = 0 Then
MsgBox ("No Project File name was specified")
Exit Sub
End If
Set rs = CurrentDb.OpenRecordset("SELECT * from tblFile")
Set Me.Recordset = rs
Me.txtDiscipline.ControlSource = "Discipline"
End Sub
Comment