Experts Exchange connects you with the people and services you need so you can get back to work.
strDESCR = Nz(DLookup("DESCR", "TBL_INV_REPORT", "CCN = '" & FRM_MAIN.CCN & "'"))
Open in new window
Dim db As DAO.Database
Dim qd As DAO.QueryDef
Dim strSQL As String
'// First, define your SQL query, with parameters:
strSQL = vbNullString
strSQL = strSQL & "PARAMETERS CNNvalue Text(255); & vbcrlf
strSQL = strSQL & "SELECT DESCR" & vbcrlf
strSQL = strSQL & "FROM TBL_INV_REPORT" & vbcrlf
strSQL = strSQL & "WHERE TBL_INV_REPORT.CCN = [CNNvalue];"
'// 2nd, create a temporary querydef object
'// (name must be unique)
Set db = CurrentDb
Set qd = db.CreateQueryDef("tmpQry", strSQL)
'// 3rd, fillup querydef parameters:
qd.Parameters("CNNvalue").Value = strCCN
'// 4th, execute the querydef
'// 5th: properly destroy objects
Set qd = Nothing
Set db = Nothing
Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.
Have a better answer? Share it in a comment.
Please enter a first name
Please enter a last name
Must be at least 4 characters long.
Join and Comment
Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.