0
QueryDef를 사용하면 " 변수 또는 With 블록 변수가 설정되지 않음"오류가 발생합니다. strSQL의 출력을 새 쿼리에 복사하면 제대로 작동합니다. 이 오류에 대한 해결책을 도우십시오.MS Access VBA QueryDef - With 블록 변수가 설정되지 않았습니다. 오류
다음 줄을 실행할 때 오류가 발생합니다.
Set qryDef = dbs.CreateQueryDef(strQueryName, strSQL)
당신은 DBS 객체를 설정 놓친 듯
Private Sub ComboReclassify_AfterUpdate()
Dim dbs As Database
Dim strSQL As String
Dim strQueryName As String
Dim qryDef As QueryDef
strQueryName = "qryST_ReclassifyAttribute"
Dim attr As String
Dim ValueID As Integer
attr = [Forms]![frm_tblST_AttributesReclassification]![ComboItemAttributes]
ValueID = [Forms]![frm_tblST_AttributesReclassification]![ComboReclassify]
strSQL = "UPDATE dbo_tblST_DepartmentsAttributes SET " & (attr) & " = " & ValueID & " WHERE dbo_tblST_DepartmentsAttributes.id = 1"
Set qryDef = dbs.CreateQueryDef(strQueryName, strSQL)
DoCmd.OpenQuery "qryST_ReclassifyAttribute"
End Sub