I've found Jon K's database/VBA codes to be very useful. However, since I switched to a new computer, I am no longer able to run his codes. To find out more about his database, please look at the thread below:
http://www.access-programmers.co.uk/forums/showthread.php?p=1172983#post1172983
So, when I try running the VBA code, I would get this error message:
Microsoft Visual Basic
Run-Time error '-2147221164 (80040154)':
Class not registered
And when I hit the debug button, the blue underline section of the code below is highlighted in yellow.
Does anyone know how I can resolve this issue? Do I need to download/register something?
Public Function Conc(Fieldx, Identity, Value, Source) As Variant
Dim cnn As ADODB.Connection
Dim rs As ADODB.Recordset
Dim SQL As String
Dim vFld As Variant
Set cnn = CurrentProject.Connection
Set rs = New ADODB.Recordset
vFld = Null
SQL = "SELECT [" & Fieldx & "] as Fld" & _
" FROM [" & Source & "]" & _
" WHERE [" & Identity & "]=" & Value
' open recordset.
rs.Open SQL, cnn, adOpenForwardOnly, adLockReadOnly
' concatenate the field.
Do While Not rs.EOF
If Not IsNull(rs!Fld) Then
vFld = vFld & ", " & rs!Fld
End If
rs.MoveNext
Loop
' remove leading comma and space.
vFld = Mid(vFld, 3)
Set cnn = Nothing
Set rs = Nothing
' return concatenated string.
Conc = vFld
End Function
Thanks.
http://www.access-programmers.co.uk/forums/showthread.php?p=1172983#post1172983
So, when I try running the VBA code, I would get this error message:
Microsoft Visual Basic
Run-Time error '-2147221164 (80040154)':
Class not registered
And when I hit the debug button, the blue underline section of the code below is highlighted in yellow.
Does anyone know how I can resolve this issue? Do I need to download/register something?
Public Function Conc(Fieldx, Identity, Value, Source) As Variant
Dim cnn As ADODB.Connection
Dim rs As ADODB.Recordset
Dim SQL As String
Dim vFld As Variant
Set cnn = CurrentProject.Connection
Set rs = New ADODB.Recordset
vFld = Null
SQL = "SELECT [" & Fieldx & "] as Fld" & _
" FROM [" & Source & "]" & _
" WHERE [" & Identity & "]=" & Value
' open recordset.
rs.Open SQL, cnn, adOpenForwardOnly, adLockReadOnly
' concatenate the field.
Do While Not rs.EOF
If Not IsNull(rs!Fld) Then
vFld = vFld & ", " & rs!Fld
End If
rs.MoveNext
Loop
' remove leading comma and space.
vFld = Mid(vFld, 3)
Set cnn = Nothing
Set rs = Nothing
' return concatenated string.
Conc = vFld
End Function
Thanks.