A
Andy Barber
Hi,
I'm trying to write an app that reads data from a table
into a string variable for later use in my program.
Below is a snippet of the code I'm using, which compiles
ok, but at runtime I get and error 'Object reference not
set to an instance of an object.' as soon as I try to
access the data in the fields, I.e. at the line that
reads 'KeyFlags(i) = rstFields("keyflag").value'
Anyone tell me where I'm going wrong?
strSQL = "SELECT fieldname, keyflag,
mandatoryflag ,vendorKey,tablename from field_relates "
strSQL = strSQL & "where fieldname = '" &
Remove_Quotes(namearray(i)) & "' AND tablename = '" &
CmdArgs(0) & "'"
Dim rstFields
rstFields = CreateObject("ADODB.Recordset")
rstFields.open(strSQL, strConn)
If rstFields.eof Then
MsgBox("**Error:- Field name " & namearray
(i) & " not registered for " & CmdArgs(0) & " load at
position " & i + 1)
FileClose(1)
Return 4
End If
KeyFlags(i) = rstFields("keyflag").value
MandatoryFlags(i) = rstFields
("mandatoryflag").value
VendorKey(i) = rstFields("VendorKey").value
If MandatoryFlags(i) = "Y" Then ManCount += 1
If VendorKey(i) = "Y" Then VenCount += 1
rstFields.close()
I'm trying to write an app that reads data from a table
into a string variable for later use in my program.
Below is a snippet of the code I'm using, which compiles
ok, but at runtime I get and error 'Object reference not
set to an instance of an object.' as soon as I try to
access the data in the fields, I.e. at the line that
reads 'KeyFlags(i) = rstFields("keyflag").value'
Anyone tell me where I'm going wrong?
strSQL = "SELECT fieldname, keyflag,
mandatoryflag ,vendorKey,tablename from field_relates "
strSQL = strSQL & "where fieldname = '" &
Remove_Quotes(namearray(i)) & "' AND tablename = '" &
CmdArgs(0) & "'"
Dim rstFields
rstFields = CreateObject("ADODB.Recordset")
rstFields.open(strSQL, strConn)
If rstFields.eof Then
MsgBox("**Error:- Field name " & namearray
(i) & " not registered for " & CmdArgs(0) & " load at
position " & i + 1)
FileClose(1)
Return 4
End If
KeyFlags(i) = rstFields("keyflag").value
MandatoryFlags(i) = rstFields
("mandatoryflag").value
VendorKey(i) = rstFields("VendorKey").value
If MandatoryFlags(i) = "Y" Then ManCount += 1
If VendorKey(i) = "Y" Then VenCount += 1
rstFields.close()