I’ve got a list box that pulls tests from a database depending on the college any particular student is in. When the student selects a test, I simply want to pull a few values out of the List box for stat tracking purposes. When I run this query, it requests I enter a parameter value.
Here is my code:
'Dim TestName As String TestName = Me.List15.Column(1) DoCmd.RunSQL ("Insert Into TestingStatistics (BadgeNumber, TestName, College, Instructor, SigninTime, Special)" _ & "VALUES (" & txtBadgeNo.Value & ", " & TestName & ", 'Medicine', 'Test', time(), 1);")
On TestName
it’s requesting that I enter a parameter value. I’ve tried running this with a messagebox and it’s pushing the right information. Even the Enter Parameter value dialog that pops up has the correct information in it as a caption.
What am I missing?
Advertisement
Answer
You need a String, not a Variant, and a space:
Dim TestName As String TestName = Nz(Me.List15.Column(1)) DoCmd.RunSQL ("Insert Into TestingStatistics (BadgeNumber, TestName, College, Instructor, SigninTime, Special) " & _ "VALUES (" & txtBadgeNo.Value & ", '" & TestName & "', 'Medicine', 'Test', Time(), 1);")