HI
I am new to VBA, I am trying to populate 10 textboxes with values from a table. I am getting "Application-defined or object-defined error" when I open the form.
Can you please find where is it going wrong?
Text boxes are named compl_01 to compl_10.
And NUMer value in sql is supposed to change to NUM01 …NUM10 with each loop.
Thanks a lot
If Measure = "CIS" Then
'Const cintLastTextBoxNum As Integer = 10
Dim i As Integer
Dim qdf As QueryDef
Dim rs As DAO.Recordset
Dim COMPl As String
Dim COMPla As String
Dim NUMer As String
Dim dba As Database
Dim sqlb As String
For i = 1 To 10
NUMer = "NUM" & Format(i, "00")
COMPla = "compl_" & Format(i, "00")
sqlb = "SELECT DISTINCT HEDIS_HYBRID_CMPL_ALL.[compliance]" _
& "FROM [HEDIS_HYBRID_CMPL_ALL]" _
& "WHERE HEDIS_HYBRID_CMPL_ALL.ENCRYPT_ID = '" & Left(Tracking_ID, 7) & "'" _
& "And HEDIS_HYBRID_CMPL_ALL.CMPL_RULE_ID = '" & NUMer & "'"
Set dba = CurrentDb
Set qdf = dba.CreateQueryDef("", sqlb)
Set rs = qdf.OpenRecordset(dbOpenSnapshot)
COMPl = ""
Do While Not rs.EOF
If COMPl = "" Then
COMPl = rs![compliance].Value
Else
COMPl = "COMPl" & "," & rs![compliance].Value
End If
rs.MoveNext
Loop
rs.Close
Set rs = Nothing
Set dba = Nothing
Set qdf = Nothing
Forms(stDocName).COMPla = COMPl
Next i
End If
I am new to VBA, I am trying to populate 10 textboxes with values from a table. I am getting "Application-defined or object-defined error" when I open the form.
Can you please find where is it going wrong?
Text boxes are named compl_01 to compl_10.
And NUMer value in sql is supposed to change to NUM01 …NUM10 with each loop.
Thanks a lot
If Measure = "CIS" Then
'Const cintLastTextBoxNum As Integer = 10
Dim i As Integer
Dim qdf As QueryDef
Dim rs As DAO.Recordset
Dim COMPl As String
Dim COMPla As String
Dim NUMer As String
Dim dba As Database
Dim sqlb As String
For i = 1 To 10
NUMer = "NUM" & Format(i, "00")
COMPla = "compl_" & Format(i, "00")
sqlb = "SELECT DISTINCT HEDIS_HYBRID_CMPL_ALL.[compliance]" _
& "FROM [HEDIS_HYBRID_CMPL_ALL]" _
& "WHERE HEDIS_HYBRID_CMPL_ALL.ENCRYPT_ID = '" & Left(Tracking_ID, 7) & "'" _
& "And HEDIS_HYBRID_CMPL_ALL.CMPL_RULE_ID = '" & NUMer & "'"
Set dba = CurrentDb
Set qdf = dba.CreateQueryDef("", sqlb)
Set rs = qdf.OpenRecordset(dbOpenSnapshot)
COMPl = ""
Do While Not rs.EOF
If COMPl = "" Then
COMPl = rs![compliance].Value
Else
COMPl = "COMPl" & "," & rs![compliance].Value
End If
rs.MoveNext
Loop
rs.Close
Set rs = Nothing
Set dba = Nothing
Set qdf = Nothing
Forms(stDocName).COMPla = COMPl
Next i
End If