Home > Software engineering >  VB editor mistakes, the master a favor, thank you first
VB editor mistakes, the master a favor, thank you first

Time:11-12

'Vorhandensein eines Feldes pr? Fen MIT ADO
The Public Function dbRecordCount (Table As String) As Long

Dim RST As ADODB. You

On Error GoTo ErrHandler
The Set RST=New ADODB. You

RST. Open the "SELECT * FROM" & amp; Create the Table, CNT 'you.
Set RST.=Nothing 'ActiveConnection Disconnect the you.
DbRecordCount=RST. RecordCount
RST. Close
The Set of RST=Nothing
The Exit Function
ErrHandler:
GErrors. DisplayError csErrSource & amp; ". AddNewRecord "
Stop
End Function

CodePudding user response:

Didn't say which error, what is wrong, you throw a piece of code, like a lie to the diagnosis and treatment to the hospital bed with the doctor say: I'm not comfortable, to see see,

Look at the code to guess your several possible error:
1, there is no reference ADO class library
2, the code inside the CNT is clearly a connection, but see you this code comments, in a foreign should be copied "on the net, is no statement did not CNT object and database connection
3, if ADO references, the connection is created, then an error is basically that the SQL statement execution error, you exactly have a Table in the database of the string is pointing to the Table name,

Question should be say compiler error, the above 1, 2, will cause a compiler error, 3 is the execution process of mistakes,
  •  Tags:  
  • VBA
  • Related