O
OD
Hi
I hope I got all the necessary procedures. I am getting the following error
when opening the database. Everything looks good until almost the end and for
some reason it looks like the db is opening up in add mode (the table is
coming back as empty and there is information in it),
An error has occurred in the application
Error Number 91
Error Description Object variable or With block variable not set
Module Source frmPurchaseEntryScreen3
procedure Source LoadRecords
Here are the processes leading to this
Private Sub Form_Load()
On Error GoTo HandleError
Set objPurchase = New clsPurchase
Set rsPurchase = New ADODB.Recordset
blnAllRecords = True
Call LoadRecords
Exit Sub
HandleError:
GeneralErrorHandler Err.Number, Err.Description, PURCHASE_FORM,
"Form_Load"
Exit Sub
End Sub
Sub LoadRecords()
On Error GoTo HandleError
intCurPurchRecord = 0
blnAddMode = False
Set rsPurchase = objPurchase.RetrievePurchase(blnAllRecords)
If rsPurchase.BOF And rsPurchase.EOF Then
MsgBox "There are no records in the database"
Exit Sub
Else
objPurchase.PopulatePropertiesFromRecordset rsPurchase
Call MoveToFirstRecord(intCurPurchRecord, rsPurchase, objPurchase,
blnAddMode)
Call PopulatePurchaseControls
End If
Exit Sub
HandleError:
GeneralErrorHandler Err.Number, Err.Description, PURCHASE_FORM,
"LoadRecords"
Exit Sub
End Sub
Function RetrievePurchase(blnAllRecords As Boolean) As ADODB.Recordset
On Error GoTo HandleError
Dim strSQLStatement As String
Dim rsPurch As New ADODB.Recordset
strSQLStatement = BuildSQLSelectPurchase(blnAllRecords)
Set rsPurch = ProcessRecordset(strSQLStatement)
Exit Function
HandleError:
GeneralErrorHandler Err.Number, Err.Description, CLS_PURCHASE,
"RetrievePurchase"
Exit Function
End Function
Function BuildSQLSelectPurchase(blnAllRecords As Boolean) As String
On Error GoTo HandleError
Dim strSQLretrieve As String
If intPurchLookup = 0 Then
strSQLretrieve = "SELECT * FROM tblPurchReq ORDER BY PRNum"
End If
BuildSQLSelectPurchase = strSQLretrieve
Exit Function
HandleError:
GeneralErrorHandler Err.Number, Err.Description, DB_LOGIC,
"BuildSQLRetrievePurchase"
Exit Function
End Function
Function ProcessRecordset(strSQLStatement As String) As ADODB.Recordset
On Error GoTo HandleError
Call OpenDBConnection
Dim rsPurch As New ADODB.Recordset
With rsPurch
.CursorType = adOpenKeyset
.CursorLocation = adUseClient
.LockType = adLockBatchOptimistic
.Open strSQLStatement, cnConn
.ActiveConnection = Nothing
End With
Call CloseDBConnection
Set ProcessRecordset = rsPurch
Exit Function
HandleError:
GeneralErrorHandler Err.Number, Err.Description, DB_LOGIC,
"ProcessRecordset"
Exit Function
End Function
I hope I got all the necessary procedures. I am getting the following error
when opening the database. Everything looks good until almost the end and for
some reason it looks like the db is opening up in add mode (the table is
coming back as empty and there is information in it),
An error has occurred in the application
Error Number 91
Error Description Object variable or With block variable not set
Module Source frmPurchaseEntryScreen3
procedure Source LoadRecords
Here are the processes leading to this
Private Sub Form_Load()
On Error GoTo HandleError
Set objPurchase = New clsPurchase
Set rsPurchase = New ADODB.Recordset
blnAllRecords = True
Call LoadRecords
Exit Sub
HandleError:
GeneralErrorHandler Err.Number, Err.Description, PURCHASE_FORM,
"Form_Load"
Exit Sub
End Sub
Sub LoadRecords()
On Error GoTo HandleError
intCurPurchRecord = 0
blnAddMode = False
Set rsPurchase = objPurchase.RetrievePurchase(blnAllRecords)
If rsPurchase.BOF And rsPurchase.EOF Then
MsgBox "There are no records in the database"
Exit Sub
Else
objPurchase.PopulatePropertiesFromRecordset rsPurchase
Call MoveToFirstRecord(intCurPurchRecord, rsPurchase, objPurchase,
blnAddMode)
Call PopulatePurchaseControls
End If
Exit Sub
HandleError:
GeneralErrorHandler Err.Number, Err.Description, PURCHASE_FORM,
"LoadRecords"
Exit Sub
End Sub
Function RetrievePurchase(blnAllRecords As Boolean) As ADODB.Recordset
On Error GoTo HandleError
Dim strSQLStatement As String
Dim rsPurch As New ADODB.Recordset
strSQLStatement = BuildSQLSelectPurchase(blnAllRecords)
Set rsPurch = ProcessRecordset(strSQLStatement)
Exit Function
HandleError:
GeneralErrorHandler Err.Number, Err.Description, CLS_PURCHASE,
"RetrievePurchase"
Exit Function
End Function
Function BuildSQLSelectPurchase(blnAllRecords As Boolean) As String
On Error GoTo HandleError
Dim strSQLretrieve As String
If intPurchLookup = 0 Then
strSQLretrieve = "SELECT * FROM tblPurchReq ORDER BY PRNum"
End If
BuildSQLSelectPurchase = strSQLretrieve
Exit Function
HandleError:
GeneralErrorHandler Err.Number, Err.Description, DB_LOGIC,
"BuildSQLRetrievePurchase"
Exit Function
End Function
Function ProcessRecordset(strSQLStatement As String) As ADODB.Recordset
On Error GoTo HandleError
Call OpenDBConnection
Dim rsPurch As New ADODB.Recordset
With rsPurch
.CursorType = adOpenKeyset
.CursorLocation = adUseClient
.LockType = adLockBatchOptimistic
.Open strSQLStatement, cnConn
.ActiveConnection = Nothing
End With
Call CloseDBConnection
Set ProcessRecordset = rsPurch
Exit Function
HandleError:
GeneralErrorHandler Err.Number, Err.Description, DB_LOGIC,
"ProcessRecordset"
Exit Function
End Function