HI. I have a table called dbo_Users1
I would like to run a SQL command to filter it down to the specific user working with the database and then get their numeric ID (BenTypeID). Here is my code:
I get a runtime error 2342 every time I try to do this. I put the SQL directly into Access and it works. Can someone point out what I am doing wrong?
I would like to run a SQL command to filter it down to the specific user working with the database and then get their numeric ID (BenTypeID). Here is my code:
Code:
getNTID = Environ("USERNAME")
strSQL2 = _
"SELECT dbo_Users1.* " & _
"FROM dbo_Users1 " & _
"WHERE dbo_Users1.[Username]='" & getNTID & "';"
Debug.Print strSQL2
DoCmd.RunSQL (strSQL2)
BenTypeID = "userid", "dbo_users1"
Set db = CurrentDb
Set rs = db.OpenRecordset(strSQL, dbOpenDynaset, dbSeeChanges)
With rs
.AddNew
!TemplateTypeID = cboTemplateType.Value
!COCID = cboCOCSeries.Value
!DocumentTypeID = cboDocType.Value
!BenefitTypeID = cboBenefitType.Value
!ImportedBy = BenTypeID
.Update
'intBatchID = !ImportBatchID
End With
I get a runtime error 2342 every time I try to do this. I put the SQL directly into Access and it works. Can someone point out what I am doing wrong?