Hi Folks,
A bit confused here.. I have an MS Access Form in which a value is entered into a Text Box, and then that value is supposed to be used as a parameter in a query (upon clicking a button next to said Text Box).
Currently, when I enter a value into the Text Box and then click the button to run the query, I receive the 'Enter Parameter Value' prompt with the current value of that Text Box as the field that it's evidently looking for. The specific value that I type into the Text Box is what shows on that dialog box. If I re-enter that value into the actual prompt and click "OK", the query then runs with expected result. So essentially, it works - but I have to enter the parameter value into the Text Box on the form, and then re-enter that same value into the 'Enter Parameter Value' prompt. The latter is what I'm confused about.
I'm sure I'm missing something obvious! Below is the code used on the form (within the 'OnClick' event of the button). Thanks!
Code:
Dim db As DAO.DatabaseDim rs As DAO.Recordset
Dim qdf As DAO.QueryDef
Dim strUserID As String
Dim strSQL As String
strUserID = Me!txtUID
strSQL = "SELECT tblImport_Final.UserID, tblImport_Final.Title, tblImport_Final.Location " & _
" FROM tblImport_Final " & _
" WHERE tblImport_Final.UserID = " & [Forms]![frmUser_Report]![txtUID]
DoCmd.DeleteObject acQuery, "tempQry"
Set db = CurrentDb
Set qdf = db.CreateQueryDef("tempQry", strSQL)
DoCmd.OpenQuery ("tempQry")